It's not a secret anymore!
The moose likes Servlets and the fly likes From Servlet to JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "From Servlet to JSP" Watch "From Servlet to JSP" New topic

From Servlet to JSP

Navi Singh
Ranch Hand

Joined: Jul 24, 2002
Posts: 80
Hi!! Good Folk's
need help again!.
I have a servlet which is invoked by a Html page.
The Html page send's data to servlet which confirms with the database and get's the data.
From here there is a simple welcome (JSP)page for the confirmed data logger's.
But i am not able to get the JSP page.
CODE IS:The Lower Part..
HttpSession userSession=req.getSession(true);

RequestDispatcher rd=getServletContext().getRequestDispatcher("http://localhost:8080/zz/jsp/welcome.jsp");
if (rd!=null)
} }
catch(Exception e)
out.println("SQLException has occurred"+e.getMessage());
The Error :--- Displayed.
SQLException has Occurred
Path http://localhost:8080/zz/jsp/welcome.jsp does not start with a "/" character
--Thank's In advance.
Mark Howard
Ranch Hand

Joined: Feb 14, 2001
Posts: 285
Hi Parvin
Check out the API for getRequestDispatcher, which has the following comment regarding the resource path:
The pathname must begin with a "/" and is interpreted as relative to the current context root. This method returns null if the ServletContext cannot return a RequestDispatcher

RequestDispatcher rd=getServletContext().getRequestDispatcher("/jsp/welcome.jsp");
Mr. C Lamont Gilbert
Ranch Hand

Joined: Oct 05, 2001
Posts: 1170

or try using request.getRequestDispatcher();
Navi Singh
Ranch Hand

Joined: Jul 24, 2002
Posts: 80
Hi! Folks,
Thank You for the solution.
It's working .
[ December 17, 2002: Message edited by: Parvin Palia ]
I agree. Here's the link:
subject: From Servlet to JSP
It's not a secret anymore!