Dear all,


I got this error message when running a servlet on JWS1.1.3

-----------------------------------------------------------------
500 Internal Server Error

The servlet named "ValidasiLoginWC", at the requested URL

     http://152.118.25.52:8080/servlet/login

reported this exception:

     ValidasiLoginWC

The administrator of this web server should resolve this problem.

-----------------------------------------------------------------


And here is the complete code

-----------------------------------------------------------------
import java.io.*;
import java.util.*;

import javax.servlet.*;
import javax.servlet.http.*;

public class LoginWebCourse extends HttpServlet
{
        String user_id;
        String user_pass;
        String passwdDir;

        public void init(ServletConfig config)
                throws ServletException
        {
                super.init(config);
                passwdDir = getInitParameter("resultsDir");
                if (passwdDir == null) {
                Enumeration initParams = getInitParameterNames();
                System.err.println("The init parameters were: ");
                while (initParams.hasMoreElements()) {
                        System.err.println(initParams.nextElement());
                }
                System.err.println("Should have seen one parameter name");
                throw new UnavailableException (this,
                        "Not given a directory to write results!");
                }
        }

        void message(String msg, HttpServletResponse res)
                        throws IOException  {
                res.setContentType("text/html");
                PrintWriter toClient = res.getWriter();
                toClient.println("<html>");
              toClient.println("<title>" + "Pesan" + "</title>");
            toClient.println(msg);
              toClient.println("</html>");
                // Close the writer; the response is done.
                toClient.close();
        }

        public void doPost(HttpServletRequest req, HttpServletResponse
res)
                throws ServletException, IOException
        {
                 user_id        =req.getParameterValues("user_id")[0];
                 user_pass      =req.getParameterValues("user_pass")[0];

                //Validasi Field Kosong
                if(user_id == "" || user_pass == ""){
                        message("Isi yang bener dong...", res);
                }
                else{
                        ValidasiLoginWC vali = new
ValidasiLoginWC(user_id, user_pass, passwdDir);
                        message(vali.cekValid(), res);
                }
        }
}

class ValidasiLoginWC {

        private String user_id;
        private String user_pass;
        private String file_pass;

        ValidasiLoginWC(String a, String b, String c){
                user_id = a;
                user_pass = b;
                file_pass = c + System.getProperty("file.separator") +
"passwd.txt";
        }

        String cekValid() throws IOException{
                FileReader resultsFile = new FileReader(file_pass);
                BufferedReader bufLine = new BufferedReader(resultsFile);
                String line;
                String token1, token2;
                int found = 1;
                while ((found != 2) && ((line = bufLine.readLine()) !=
null)){
                        StringTokenizer t = new StringTokenizer (line,
"|");
                        token1 = t.nextToken();
                        token2 = t.nextToken();
                        if (cekUser(token1)){
                                found = 2;
                                if(valid(token1, token2)){
                                        return "Login OK";
                                }
                                else{
                                        return "Password salah";
                                }
                        }
            }
                if (found == 1){
                        return "Nggak ada userid tsb";
                }
                return "";
        }

        boolean cekUser(String satu){
                if(satu.equals(user_id)){
                        return true;
                }
                else{
                        return false;
                }
        }

        boolean valid(String satu, String dua){
                if( (satu.equals(user_id)) && (dua.equals(user_pass))){
                        return true;
                }
                else{
                        return false;
                }
        }
}

---------------------------------------------------------------------

I am wondering why, 'cause the error message didn't tell what is wrong
with that servlet.

Could anyone help me ?
Thank you in advance.

Regards,
Ika Alfina

------------------------------------------------------------------
Ika Alfina ([EMAIL PROTECTED])
Dept. of Computer Science           * You are what you think  >:->
University of Indonesia             * You feel what you want   :-)

___________________________________________________________________________
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