A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
JavaRanch
»
Java Forums
»
Java
»
JSP
Author
correct code to comeback to home page
arekonda ramesh babu
Ranch Hand
Joined: Apr 11, 2006
Posts: 35
posted
Feb 01, 2007 04:49:00
0
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
posted
Feb 01, 2007 05:25:00
0
<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: 56232
13
I like...
posted
Feb 01, 2007 08:52:00
0
Milan Jagatiya's code has an error.
If you are using
JSP
1.2, the code to get the context path is
<%= request.getContextPath() %>
in JSP 2.0, it should be (no scriptlets):
${pageContext.request.contextPath}
[
Smart Questions
] [
JSP FAQ
] [
Books by Bear
] [
Bear's FrontMan
] [
About Bear
]
Milan Jagatiya
Ranch Hand
Joined: Jan 01, 2007
Posts: 164
posted
Feb 07, 2007 05:22:00
0
<a href=<%request.getContextPath()%>"/index.jsp">home </a>
yeah Bear,...it was an error...
<a href="<%=request.getContextPath()%>/index.jsp">home</a>
[ February 07, 2007: Message edited by: Milan Jagatiya ]
I agree. Here's the link:
http://ej-technologies/jprofiler
- if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
subject: correct code to comeback to home page
Similar Threads
Request Dispatcher problem
NullPointerException: Module 'null' not found
Setting the path of servlet and jsp pages
Resin with Apache
Global forwards in Struts modules
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter