This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSP and the fly likes correct code to comeback to home page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "correct code to comeback to home page" Watch "correct code to comeback to home page" New topic
Author

correct code to comeback to home page

arekonda ramesh babu
Ranch Hand

Joined: Apr 11, 2006
Posts: 35
i have one webapplication in that index.jsp is called by default.

i have made one jsp folder and placed two jsp files namingly...

"hai.jsp" and "MyJsp.jsp".

i write in "hai.jsp" the following code to come back to "index.jsp"

<a href="/index.jsp">home </a> and tried to click the home link .

HTTP Status 404 - /index.jsp

--------------------------------------------------------------------------------

type Status report

message /index.jsp

description The requested resource (/index.jsp) is not available.


--------------------------------------------------------------------------------

Apache Tomcat/5.5.20

is encountered.

"<a href="/index.jsp">" is this code is right one to do so?

how to correct my mistake

do needful to me

Rameshbabu

Milan Jagatiya
Ranch Hand

Joined: Jan 01, 2007
Posts: 164

<a href="/index.jsp">home </a>

because of you are not getting context path there....
use below line...

[code]
<a href=<%request.getContextPath()%>"/index.jsp">home </a>
[code]


Milan.<br />I can because I think I can...
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60766
    
  65

Milan Jagatiya's code has an error.

If you are using JSP 1.2, the code to get the context path is



in JSP 2.0, it should be (no scriptlets):



[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Milan Jagatiya
Ranch Hand

Joined: Jan 01, 2007
Posts: 164




yeah Bear,...it was an error...

[ February 07, 2007: Message edited by: Milan Jagatiya ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: correct code to comeback to home page
 
Similar Threads
Request Dispatcher problem
Global forwards in Struts modules
Resin with Apache
Setting the path of servlet and jsp pages
NullPointerException: Module 'null' not found