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 / August 2006

Tip: Looking for answers? Try searching our database.

how do I get a path from a servlet?

Thread view: 
laredotornado@zipmail.com - 25 Aug 2006 14:44 GMT
Hello,

I have a page -- <public html dir>/app1/form.jsp that submits via POST
to a servlet, MyServlet.  Within the doPost() method of MyServlet, I do
some stuff, and then want to redirect back to <public html dir>/app1/
without hard-coding "app1".

How can I do this?

Thanks, - Dave
M.J. Dance - 25 Aug 2006 14:49 GMT
> Hello,
>
[quoted text clipped - 4 lines]
>
> How can I do this?

Strip form.jsp from referer.
laredotornado@zipmail.com - 25 Aug 2006 20:51 GMT
Am I guaranteed to get the referer each time?  If not, are there any
other ways?

> > Hello,
> >
[quoted text clipped - 6 lines]
>
> Strip form.jsp from referer.
M.J. Dance - 28 Aug 2006 11:50 GMT
> Am I guaranteed to get the referer each time?

No.

> If not, are there any
> other ways?

From within a servlet: store the URI into some request-scope bean.
From within a jsp: use that bean to obtain the stored URI.

Or vice versa.
~Glynne - 25 Aug 2006 21:06 GMT
> Hello,
>
[quoted text clipped - 6 lines]
>
> Thanks, - Dave

Read the path from a properties file located in the same directory as
your class file where the classloader can find it.  That way you can
update the properties file anytime you like without needing to restart
the service.  For example, for a file named "MyServlet.properties" do
something like this within your servlet.

   public void
   doGet( HttpServletRequest req, HttpServletResponse resp )
   throws IOException, ServletException
   {
       try {
         ResourceBundle rb= null;
         rb= rb.getBundle( "MyServlet", req.getLocale() );
         String sBasePath= rb.getString("basePath");

~Glynne


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.