_Esam
asked on
How to Navigate among 3 JSP ?
How to Navigate between JSP pages?
Hi,
I can't seem to navigate among 3 JSP pages.
Here is what I did.
I have the first JSP page where I have:
<BODY>
Welcome to Hello1
<form action="../Hello1" method="POST"> //since the servlet Hello1 is at JavaSource package and
//the Hello1.jsp is at WebContest/jsp/Hello1.jsp
<input type="submit" value="Process Hello1" >
</form>
</BODY>
Inside the Hello1.java Servlet, I have...
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
try{
getServletContext().getReq uestDispat cher("/jsp /Hello2.js p").forwar d(request, response);
System.out.println("Inside Hello1 Servlet");
Logger.log(Hello1.class, Logger.ERROR, "Inside Hello1 Servlet");
}
catch(Exception nEx){
Logger.log(Hello1.class, Logger.ERROR, "ERROR: Inside Hello1 Servlet", nEx.getMessage());
}
}
NOW I can come from Hello1.jsp thru the servlet to the Hello2.jsp
Now Here is what I have in Hello2.jsp
<BODY>
Welcome to Hello2
<form action="../Hello2" method="get">
<input type="submit" value="Process Hello1" >
</form>
</BODY>
Now insider Hello2.java servlet.... I have:
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
try{
getServletContext().getReq uestDispat cher("/jsp /Hello3.js p").forwar d(request, response);
System.out.println("Inside Hello1 Servlet");
Logger.log(Hello1.class, Logger.ERROR, "Inside Hello2 Servlet");
}
catch(Exception nEx){
Logger.log(Hello1.class, Logger.ERROR, "ERROR: Inside Hello2 Servlet", nEx.getMessage());
}
}
Now, I can't seem to go to Hello3.jsp ..
The explorer is saying can't find the resources ??
What should I do to make it work?
Let me know.
Thax.
_Esam.
Hi,
I can't seem to navigate among 3 JSP pages.
Here is what I did.
I have the first JSP page where I have:
<BODY>
Welcome to Hello1
<form action="../Hello1" method="POST"> //since the servlet Hello1 is at JavaSource package and
//the Hello1.jsp is at WebContest/jsp/Hello1.jsp
<input type="submit" value="Process Hello1" >
</form>
</BODY>
Inside the Hello1.java Servlet, I have...
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
try{
getServletContext().getReq
System.out.println("Inside
Logger.log(Hello1.class, Logger.ERROR, "Inside Hello1 Servlet");
}
catch(Exception nEx){
Logger.log(Hello1.class, Logger.ERROR, "ERROR: Inside Hello1 Servlet", nEx.getMessage());
}
}
NOW I can come from Hello1.jsp thru the servlet to the Hello2.jsp
Now Here is what I have in Hello2.jsp
<BODY>
Welcome to Hello2
<form action="../Hello2" method="get">
<input type="submit" value="Process Hello1" >
</form>
</BODY>
Now insider Hello2.java servlet.... I have:
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
try{
getServletContext().getReq
System.out.println("Inside
Logger.log(Hello1.class, Logger.ERROR, "Inside Hello2 Servlet");
}
catch(Exception nEx){
Logger.log(Hello1.class, Logger.ERROR, "ERROR: Inside Hello2 Servlet", nEx.getMessage());
}
}
Now, I can't seem to go to Hello3.jsp ..
The explorer is saying can't find the resources ??
What should I do to make it work?
Let me know.
Thax.
_Esam.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Great -- glad to help.
ASKER
I undsertood the relative path thing also while testing them.
Since my JSP's were under jsp folder I tried like:
From Hello1.jsp
<form action="../servlet/Hello1"
Inside Hello1.java
getServletContext().getReq
From Hello2.jsp
<form action="../servlet/Hello2"
Insicde Hello2.java
getServletContext().getReq
and they did work fine.
Thanks a lot..
Regards,
_Esam.