• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

From Servlet to JSP

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