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