• 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

problem using requestdispatcher interface

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm trying to load JSP files from servlets.but this program is nort working. can anyone tell me ehat might be the problem.


import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class Login extends HttpServlet{

public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException,IOException{


String userId = req.getParameter("userId");
String password = req.getParameter("password");

String uName =userId;

// if uName is null .. user is not authorized.

if (uName == null)
{

PrintWriter ot = res.getWriter();
ot.println(" Please verify the Userid and password");
ot.close();
}
else
{

// So the user is valid let's create a seesion // for this user.

HttpSession userSession = req.getSession(true);

// put the user name session variable.

userSession.putValue("userName", uName);

// now we need to transfer the control to welcome.jsp

RequestDispatcher rd =
getServletContext().getRequestDispatcher("/welcome.jsp");

if (rd != null)
{
rd.forward(req,res);
}

}


}// end of doPost

}// end of servlet class

thanks in advance.
bye
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not exactly an Ant question is it? Moving to the Servlets forum.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What do you mean "not working"? Are you seeing errors in the browser window, in your logs?
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic