my dog learned polymorphism
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

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "problem: jsp:forword page="../../web/abc.jsp"" Watch "problem: jsp:forword page="../../web/abc.jsp"" New topic

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


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 "" it works. I panic now.
Do you know what could cause this situation? Please help me.

Java, milk...
Peter den Haan
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Originally posted by zystation:
I tried to switch page to website such as "" 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(""); %>.
- Peter

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).]

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
The javaranch has a naming policy and your login name does not meet the requirement.
Please signup again with a proper name.
I agree. Here's the link:
subject: problem: jsp:forword page="../../web/abc.jsp"
It's not a secret anymore!