Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » How to read a external file after deployment?
How to read a external file after deployment? [message #885626] Wed, 13 June 2012 10:52 Go to next message
ZungNV Abel is currently offline ZungNV AbelFriend
Messages: 16
Registered: November 2010
Junior Member
Dear community,
I have an application built on RAP. In my application, I have a list of Strings. I want to have content of these strings configurable from an external file (e.g xml file) when user enter website. My app will read content of that file and the website will display the respective content (it's kind of config file).
For example, the path to website is as following:
{TOMCAT_HOME}/webapps/{my_app}/WEB-INF
After deployment, I want to add a file .xml to category WEB_INF, then my website will read the content of that file.
My question is how I can know the path of my app in webserver after deployment, because eclipse wrap the whole project into bundle. Or is there any other way to solve my problem?
Thank you very much!


Re: How to read a external file after deployment? [message #885657 is a reply to message #885626] Wed, 13 June 2012 12:06 Go to previous messageGo to next message
Avrajit Chatterjee is currently offline Avrajit ChatterjeeFriend
Messages: 68
Registered: September 2011
Member
RWT.getRequest().getServletContext().getRealPath("/") will give you the absolute path of your installation. I guess this solves your issue. You just need make sure of one thing that you access RWT.getRequest with a http request.
Re: How to read a external file after deployment? [message #886149 is a reply to message #885657] Thu, 14 June 2012 10:35 Go to previous messageGo to next message
ZungNV Abel is currently offline ZungNV AbelFriend
Messages: 16
Registered: November 2010
Junior Member
Hi Avrajit,
Thanks for your answer.
I followed your suggestion but I got the error as following:
Could not create the view: javax.servlet.http.HttpServletRequest.getServletContext()Ljavax/servlet/ServletContext;

The error line is in the area where I initiate layout of a view.
I got null here:
RWT.getRequest().getServletContext().getRealPath("/")


Re: How to read a external file after deployment? [message #886608 is a reply to message #886149] Fri, 15 June 2012 09:18 Go to previous message
Ralf Sternberg is currently offline Ralf SternbergFriend
Messages: 1313
Registered: July 2009
Senior Member

Currently, you can only access the context location using internal API:

RWTFactory.getConfiguration().getContextDirectory()

Feel free to open a feature request [1] for a public API and explain why
it is needed.

[1] http://eclipse.org/rap/bugs/

--
Ralf Sternberg

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Previous Topic:Articles about "Create a WAR from RAP Application with Libra WAR Product"
Next Topic:Probably simple -- need to add links to page
Goto Forum:
  


Current Time: Thu Mar 28 18:26:14 GMT 2024

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

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

Back to the top