• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

From Servlet to JSP

 
Navi Singh
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 285
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1170
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
or try using request.getRequestDispatcher();
 
Navi Singh
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi! Folks,
Thank You for the solution.
It's working .
--Praven
[ December 17, 2002: Message edited by: Parvin Palia ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic