Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » How to getRealPath?
How to getRealPath? [message #103516] Fri, 29 August 2008 14:30 Go to next message
Nikolai Raitsev is currently offline Nikolai RaitsevFriend
Messages: 102
Registered: July 2009
Senior Member
Hi,

my actual question is how to resolve
ServletContext#getRealPath("/something")?

It returns null if I call

ServletContext sc = RWT.getRequest().getSession().getServletContext();
System.out.println("sc.getRealPath " + sc.getRealPath("/BIRTImages"));

what is solution here?

Best regards,

Nikolai
Re: How to getRealPath? [message #103685 is a reply to message #103516] Fri, 29 August 2008 22:50 Go to previous messageGo to next message
Nikolai Raitsev is currently offline Nikolai RaitsevFriend
Messages: 102
Registered: July 2009
Senior Member
Hi,

I found ContextProvider#getWebAppBase() in package
org.eclipse.ui.internal.service, bundle org.eclipse.ui.workbench.

This give me the real path of the webapp context. But it is an INTERNAL
class, if I call it, i "break" the access restriction...

knows someone an alternative?

regards,

Nikolai
Re: How to getRealPath? [message #103812 is a reply to message #103685] Mon, 01 September 2008 15:57 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: rherrmann.innoopract.com

Nikolai,

the return value of getWebAppBase() itself is based on
ServleContext.getRealPath( "/" );. Not sure what goes wrong. Did you
try both appraoches in the exact same environment?

The JavaDoc for getRealPath says:
[...] This method returns null if the servlet container
cannot translate the virtual path to a real path for any
reason (such as when the content is being made available
from a .war archive)

HTH
Rüdiger

Nikolai wrote:
> Hi,
>
> I found ContextProvider#getWebAppBase() in package
> org.eclipse.ui.internal.service, bundle org.eclipse.ui.workbench.
>
> This give me the real path of the webapp context. But it is an INTERNAL
> class, if I call it, i "break" the access restriction...
>
> knows someone an alternative?
>
> regards,
>
> Nikolai
>
Re: How to getRealPath? [message #103884 is a reply to message #103812] Tue, 02 September 2008 08:14 Go to previous messageGo to next message
Nikolai Raitsev is currently offline Nikolai RaitsevFriend
Messages: 102
Registered: July 2009
Senior Member
Hi Rüdiger,

thank you for the answer.

I tryed 2 ways, but the code is the same (starting my RAP-App):

public int createUI() {
System.out.println("ContextProvider.getWebAppBase() " +
ContextProvider.getWebAppBase());
ServletContext sc = RWT.getRequest().getSession().getServletContext();
System.out.println("sc.getRealPath(\"/\") " + sc.getRealPath("/"));
//
//
... my app code
}

1. Printout Running from eclipse:
ContextProvider.getWebAppBase() C:\Programme\Eclipse\eclipse 3.4
canymede\workspace\.metadata\.plugins\org.eclipse.rap.ui\con text
sc.getRealPath("/") null

2. Printout Running on tomcat:
ContextProvider.getWebAppBase()
C:\Projekte\Servers\apache-tomcat-6.0.16\apache-tomcat-6.0.1 6\work\Catalina\localhost\myApp\eclipse\workspace\.metadata\ .plugins\org.eclipse.rap.ui\context
sc.getRealPath("/")
C:\Projekte\Servers\apache-tomcat-6.0.16\apache-tomcat-6.0.1 6\webapps\myApp\

I see, that on tomcat getWebAppBase and getRealPath give me differenced
"working paths". I think, that getRealPath in Eclipse return null, because
webapp-folder does not exist, but only working-folder. And for my work
(I'm trying to integrate BIRT-Reporting in my RAP-Application), I want to
save session dependent report (chart-)images in working directory and
delete it if session ends. How can I do that, without
ContextProvider.getWebAppBase()?


Best regards,

Nikolai


Rüdiger Herrmann wrote:

> Nikolai,

> the return value of getWebAppBase() itself is based on
> ServleContext.getRealPath( "/" );. Not sure what goes wrong. Did you
> try both appraoches in the exact same environment?

> The JavaDoc for getRealPath says:
> [...] This method returns null if the servlet container
> cannot translate the virtual path to a real path for any
> reason (such as when the content is being made available
> from a .war archive)

> HTH
> Rüdiger

> Nikolai wrote:
>> Hi,
>>
>> I found ContextProvider#getWebAppBase() in package
>> org.eclipse.ui.internal.service, bundle org.eclipse.ui.workbench.
>>
>> This give me the real path of the webapp context. But it is an INTERNAL
>> class, if I call it, i "break" the access restriction...
>>
>> knows someone an alternative?
>>
>> regards,
>>
>> Nikolai
>>
Re: How to getRealPath? [message #103925 is a reply to message #103884] Tue, 02 September 2008 13:46 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: fappel.innoopract.com

Hi,

here is just an alternative idea that may work in your case. You could
use the statelocation of a bundle to save the reports to disk. Here is
an example to get the statelocation of the org.eclipse.rap.ui bundle:

Bundle bundle = Platform.getBundle( PlatformUI.PLUGIN_ID );
IPath stateLocation = Platform.getStateLocation( bundle );

To create the path to a session unique folder you could use

IPath sessionLocation = stateLocation.append(
RWT.getSessionStore().getId() );

and afterwards create that folder on disk. You can use a
SessionStoreListener to remove the folder and its content from disk on
session timeout.

To show the chart on the client you can use the browser widget that
requests the chart to show by addressing a IServiceHandler. The
servicehandler reads the file from disk and delivers it to the
requesting browser widget. There should be several threads in this
newsgroup for more detail on how servicehandlers are used.

Surely there may be several downside on this approach, but if it fits or
not depends on your needs...


Ciao
Frank

-----Ursprüngliche Nachricht-----
Von: Nikolai [mailto:nikolai.raitsev@gmail.com]
Bereitgestellt: Dienstag, 2. September 2008 10:15
Bereitgestellt in: eclipse.technology.rap
Unterhaltung: How to getRealPath?
Betreff: Re: How to getRealPath?

Hi Rüdiger,

thank you for the answer.

I tryed 2 ways, but the code is the same (starting my RAP-App):

public int createUI() {
System.out.println("ContextProvider.getWebAppBase() " +
ContextProvider.getWebAppBase());
ServletContext sc = RWT.getRequest().getSession().getServletContext();
System.out.println("sc.getRealPath(\"/\") " + sc.getRealPath("/"));
//
//
... my app code
}

1. Printout Running from eclipse:
ContextProvider.getWebAppBase() C:\Programme\Eclipse\eclipse 3.4
canymede\workspace\.metadata\.plugins\org.eclipse.rap.ui\con text
sc.getRealPath("/") null

2. Printout Running on tomcat:
ContextProvider.getWebAppBase()
C:\Projekte\Servers\apache-tomcat-6.0.16\apache-tomcat-6.0.1 6\work\Catal
ina\localhost\myApp\eclipse\workspace\.metadata\.plugins\org .eclipse.rap
..ui\context
sc.getRealPath("/")
C:\Projekte\Servers\apache-tomcat-6.0.16\apache-tomcat-6.0.1 6\webapps\my
App\

I see, that on tomcat getWebAppBase and getRealPath give me differenced
"working paths". I think, that getRealPath in Eclipse return null,
because
webapp-folder does not exist, but only working-folder. And for my work
(I'm trying to integrate BIRT-Reporting in my RAP-Application), I want
to
save session dependent report (chart-)images in working directory and
delete it if session ends. How can I do that, without
ContextProvider.getWebAppBase()?


Best regards,

Nikolai


Rüdiger Herrmann wrote:

> Nikolai,

> the return value of getWebAppBase() itself is based on
> ServleContext.getRealPath( "/" );. Not sure what goes wrong. Did you
> try both appraoches in the exact same environment?

> The JavaDoc for getRealPath says:
> [...] This method returns null if the servlet container
> cannot translate the virtual path to a real path for any
> reason (such as when the content is being made available
> from a .war archive)

> HTH
> Rüdiger

> Nikolai wrote:
>> Hi,
>>
>> I found ContextProvider#getWebAppBase() in package
>> org.eclipse.ui.internal.service, bundle org.eclipse.ui.workbench.
>>
>> This give me the real path of the webapp context. But it is an
INTERNAL
>> class, if I call it, i "break" the access restriction...
>>
>> knows someone an alternative?
>>
>> regards,
>>
>> Nikolai
>>
Re: How to getRealPath? [message #103967 is a reply to message #103925] Tue, 02 September 2008 19:55 Go to previous message
Nikolai Raitsev is currently offline Nikolai RaitsevFriend
Messages: 102
Registered: July 2009
Senior Member
Hi Frank,

thank you for the tipp, I will test it, but I dont know whether
IServiceHandler is suitable way for me (now). At the moment I generate
Reports to ByteArrayOutputStream, convert it to String, and set it to
browser-widget with setText and it works in RCP and in RAP. I think, if
the reports become larger, I get a problem with, but now my focus is on
the BIRT integration in RCP an RAP, its unfortunately unstable on my
environment (I get sometimes unexplainable ClassNotFoundErrors:
http://www.eclipse.org/newsportal/article.php?id=4195&gr oup=eclipse.technology.rap#4195)...

Gruß,

Nikolai


Frank Appel wrote:

> Hi,

> here is just an alternative idea that may work in your case. You could
> use the statelocation of a bundle to save the reports to disk. Here is
> an example to get the statelocation of the org.eclipse.rap.ui bundle:

> Bundle bundle = Platform.getBundle( PlatformUI.PLUGIN_ID );
> IPath stateLocation = Platform.getStateLocation( bundle );

> To create the path to a session unique folder you could use

> IPath sessionLocation = stateLocation.append(
> RWT.getSessionStore().getId() );

> and afterwards create that folder on disk. You can use a
> SessionStoreListener to remove the folder and its content from disk on
> session timeout.

> To show the chart on the client you can use the browser widget that
> requests the chart to show by addressing a IServiceHandler. The
> servicehandler reads the file from disk and delivers it to the
> requesting browser widget. There should be several threads in this
> newsgroup for more detail on how servicehandlers are used.

> Surely there may be several downside on this approach, but if it fits or
> not depends on your needs...


> Ciao
> Frank
Previous Topic:Dialog with Icon
Next Topic:Application Crashes inTomcat
Goto Forum:
  


Current Time: Thu Apr 18 01:41:02 GMT 2024

Powered by FUDForum. Page generated in 0.02142 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top