This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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.
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
Joined: May 04, 2001
"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?
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
Thank you, Peter and Mike, I use absolute paths and it works.