• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 230
  • Last Modified:

Creating a Servlet

I have a file that is evidently a java file that needs to be compiled to a class file. When I try to compile it, I get a lot of errors "cannot resolve symbol". I am using jdk1.3.1_02. Here is the file I am trying to compile.Can anyone help me with this????

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import com.merck.is.arch.Authenticate;
import com.merck.is.arch.Authenticate.PDCNotFoundException;

public class AuthServletDemo extends HttpServlet {

  //Initialize global variables
  public void init(ServletConfig config) throws ServletException {
    super.init(config);
  }

  //Process the HTTP Post request
  public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    //get the logon credentials
    String sUser = (String) request.getParameter("isid");
    String sPassword = (String) request.getParameter("password");
    String sDomain = (String) request.getParameter("domain");

    String sMessage = new String("");
    try{
      Authenticate.NTAuthenticate(sDomain, sUser, sPassword);
      sMessage += sUser + "is authenticated.";
    }
    catch (PDCNotFoundException nfe)
    {
      sMessage += "Cannot authenticate the user. Unable to find a domain controller.";
    }
    catch (SecurityException se)
    {
      sMessage += sUser + " is NOT valid. Cannot authenticate.";
    }
    response.setContentType("text/html");
    PrintWriter out = new PrintWriter (response.getOutputStream());
    out.println("<html>");
    out.println("<head><title>AuthServletDemo</title></head>");
    out.println("<body>");
    out.println(sMessage);
    out.println("</body></html>");
    out.close();
  }
}
0
tomhughes
Asked:
tomhughes
  • 3
1 Solution
 
cheekycjCommented:
do you have the j2ee servlets.jar and com.merck.* classes in your classpath.

download the j2ee sdk:
http://java.sun.com/products/servlet/download.html

here is a good guide on how to compile servlets:
http://developer.java.sun.com/developer/onlineTraining/webcasts/pdf/webcamp/dchen/dchen2.pdf

what you want to do is after you download the j2ee sdk.

you want to add the jar (servlets.jar or whatever it is called now) to your classpath.

CJ
0
 
cheekycjCommented:
I found a great step by step guide:
http://novocode.de/doc/servlet-essentials/appendix.html
0
 
cheekycjCommented:
the jar if you download the jsdk (java servlet development kit) is jsdk.jar

CJ
0
 
kennethxuCommented:
can you tell us what server are you using?

also, please post the error message, if it is a lot, just post first 10 errors.
0
 
tomhughesAuthor Commented:
Thanks cheekyci
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now