Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / September 2007

Tip: Looking for answers? Try searching our database.

Serving files belonging to the web application directory

Thread view: 
getsanjay.sharma@gmail.com - 28 Sep 2007 20:03 GMT
Hello to all Java programmers out there.

The task I am trying to do here is to serve or access files which
belong to my web application (i.e. present in the WEB-INF/xml
directory) in a servlet. I could have hardcoded the path but what I am
looking for is a solution which employs relative paths.

Attempting to do new File("./xml/Data.xml") doesn't yield the desired
results considering that it starts looking for this folder structure
inside the bin directory of my App server.

Also, would it be a good programming / design practice to format the
data at the server and then serve the client, relieving the client of
knowing what attributes it should be looking for in the response in
case of an Ajax XML response or to send raw data in the form of XML to
the client and let it figure out how the data should be displayed?

Thanks and regards,
S T S
Mike Schilling - 28 Sep 2007 20:09 GMT
> Hello to all Java programmers out there.
>
> The task I am trying to do here is to serve or access files which
> belong to my web application (i.e. present in the WEB-INF/xml
> directory) in a servlet. I could have hardcoded the path but what I am
> looking for is a solution which employs relative paths.

Look at the ServletContext class, in particular ServletContext
.getResource().
getsanjay.sharma@gmail.com - 30 Sep 2007 18:28 GMT
On Sep 29, 12:09 am, "Mike Schilling" <mscottschill...@hotmail.com>
wrote:
> getsanjay.sha...@gmail.com wrote:
> > Hello to all Java programmers out there.
[quoted text clipped - 6 lines]
> Look at the ServletContext class, in particular ServletContext
> .getResource().

That did the trick, thanks a lot, I really appreciate your timely
help.

So my next question is:
Would it be a good programming / design practice to format the data at
the server and then serve the client, relieving the client of knowing
what attributes it should be looking for in the response in case of an
Ajax XML response or to send raw data in the form of XML to the client
and let it figure out how the data should be displayed?


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.