Hi all:

I�m starting with servlets and i went to WDVL (Building a web application servlets.jsp)
http://wdvl.internet.com/Authoring/Java/Servlets/index.html and found a tutorial about 
how to make a servlet call a .jsp. But I just copy.paste, and is not working, here is 
the code and the error maybe you can helpme, thanks.

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

public class Login extends HttpServlet {

  //Process the HTTP Post request
  public void doPost(HttpServletRequest req, HttpServletResponse res)
                        throws ServletException, IOException {
    //
    String userId = req.getParameter("userId");
    String password = req.getParameter("password");

/************************************************************
** call a method to validate the password which will return the
** User Name for authorized users and null string for un-authorised.
**********************************************************/
    String uName = validateUser(userId, password);
// if uName is null.. user is no 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("/sevlets/WDVLTut/welcome.jsp");

           if (rd != null)
              {
               rd.forward(req,res);
              }
            }
       }// end of doPost
     }// end of servlet class
***************************************************************

error message:
D:\servlets\WDVLTut>javac -d d:\JRun\servlets *.java
Login.java:21: Method validateUser(java.lang.String, java.lang.String) not found in 
class WDVLTut.Login.
    String uName = validateUser(userId, password);
                               ^
Login.java:41: Method getRequestDispatcher(java.lang.String) not found in interface 
javax.servlet.ServletContext.
           RequestDispatcher rd = 
context.getRequestDispatcher("/sevlets/WDVLTut/welcome.jsp");
                                                              ^
2 errors

Process completed with exit code 1
*************************************************************
compaling batch file:
REM  Compile and deploy
REM
set CLASSPATH=d:\JRun\lib\servlet.jar;d:\JRun\servlets
javac -d d:\JRun\servlets *.java
**************************************************************
Thanks a lot

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to