File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "From Servlet to JSP" Watch "From Servlet to JSP" New topic
Author

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);
userSession.setAttribute("userName",ar);

RequestDispatcher rd=getServletContext().getRequestDispatcher("http://localhost:8080/zz/jsp/welcome.jsp");
if (rd!=null)
{
rd.forward(req,res);
} }
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.
-Praveen
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

Try:
RequestDispatcher rd=getServletContext().getRequestDispatcher("/jsp/welcome.jsp");
Mark.
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 .
--Praven
[ December 17, 2002: Message edited by: Parvin Palia ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: From Servlet to JSP
 
Similar Threads
where to keep .jar file that is called in jsp page
Can I use Servlet Session in JSP Page.
How to access a JSP Page-Urgent
Running self made Servlets on tomcat
Professional JSP 2nd edition ch06 errors