Two Laptop Bag*
The moose likes Servlets and the fly likes problem: jsp:forword page= Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "problem: jsp:forword page="../../web/abc.jsp"" Watch "problem: jsp:forword page="../../web/abc.jsp"" New topic
Author

problem: jsp:forword page="../../web/abc.jsp"

zystation
Greenhorn

Joined: May 04, 2001
Posts: 8
I can only switch the pages within the same folder but the pages at another folder.
I tried to switch page to website such as "www.yahoo.com" it works. I panic now.
Do you know what could cause this situation? Please help me.


Java, milk...
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Originally posted by zystation:
I tried to switch page to website such as "www.yahoo.com" it works. I panic now.

Calm down now. Everything's fine
Please realise that a forward is an indication to the servlet engine that another servlet (jsp) should take over processing the request. You can only forward to different place within the same web-application! Forwarding to yahoo would mean that the browser sends its request to you and then gets its response from yahoo. That is simply impossible - TCP/IP doesn't work that way.
There is a solution, of course. The server can send a response to the browser which basically says "please look here for this information". This is a "temporary redirect" response, and you can generate it using <% response.sendRedirect("http://www.yahoo.com"); %>.
- Peter
zystation
Greenhorn

Joined: May 04, 2001
Posts: 8
"login.jsp" is in 'login' folder, once user confirms the entry the page automatic switch to "loginValidate.jsp" in 'login' folder. if user info incorrect, it goes back to "login.jsp", it works fine. Whereas it should go to "abc.jsp" that in 'web' folder. However, it doesn't go through to "abc.jsp". WHY?
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

i'm not entirely clear on how it works with the jsp:forward tag, but when I program servlets I get a requestdispatcher object, and the path to the file always starts with "/". And this is the web root. So if your site is like
< webroot >/login
< webroot >/web

Then all you'd need is "/web/abc.jsp"

I think the key is not to use relative paths (no ..) but to use absolute paths from the web root.
[This message has been edited by Mike Curwen (edited May 04, 2001).]
zystation
Greenhorn

Joined: May 04, 2001
Posts: 8
Thank you, Peter and Mike, I use absolute paths and it works.
Maky Chopra
Ranch Hand

Joined: Apr 11, 2001
Posts: 149
zystation,
The javaranch has a naming policy and your login name does not meet the requirement.
Please signup again with a proper name.
Thanks..
 
GeeCON Prague 2014
 
subject: problem: jsp:forword page="../../web/abc.jsp"