• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
zystation
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you, Peter and Mike, I use absolute paths and it works.
 
Maky Chopra
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
zystation,
The javaranch has a naming policy and your login name does not meet the requirement.
Please signup again with a proper name.
Thanks..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic