File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes problem using requestdispatcher interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "problem using requestdispatcher interface" Watch "problem using requestdispatcher interface" New topic

problem using requestdispatcher interface

swichika reddy

Joined: Dec 28, 2004
Posts: 20
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 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");

// 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 =

if (rd != null)


}// end of doPost

}// end of servlet class

thanks in advance.
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63866

Not exactly an Ant question is it? Moving to the Servlets forum.

[Asking smart questions] [About Bear] [Books by Bear]
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

What do you mean "not working"? Are you seeing errors in the browser window, in your logs?

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
I agree. Here's the link:
subject: problem using requestdispatcher interface
It's not a secret anymore!