Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

From Servlet to JSP

 
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
 
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.
 
Ranch Hand
Posts: 1170
Hibernate Eclipse IDE 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 ]
 
Here. Have a potato. I grew it in my armpit. And from my other armpit, this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic