wood burning stoves 2.0*
The moose likes Tomcat and the fly likes http status 500 error in tomcat 6,when i try to run a simple login servlet for entering name & pwd Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Products » Tomcat
Bookmark "http status 500 error in tomcat 6,when i try to run a simple login servlet for entering name & pwd" Watch "http status 500 error in tomcat 6,when i try to run a simple login servlet for entering name & pwd" New topic
Author

http status 500 error in tomcat 6,when i try to run a simple login servlet for entering name & pwd

narayan ks
Greenhorn

Joined: Dec 24, 2012
Posts: 1

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

java.lang.NullPointerException
com.lala.servlets.LoginServlet.service(LoginServlet.java:14)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


Dec 26, 2012 1:16:18 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet LoginServlet threw exception
java.lang.NullPointerException
at com.lala.servlets.LoginServlet.service(LoginServlet.java:14)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
at java.lang.Thread.run(Unknown Source)
code:
package com.lala.servlets;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class LoginServlet extends HttpServlet{
public void init(ServletConfig sc){
System.out.println("init() login servlet");
}
public void service(HttpServletRequest req,HttpServletResponse res)throws IOException,ServletException{
System.out.println("service() login servlet");
String un=req.getParameter("username");
String pw=req.getParameter("password");
String msg=" ";
if(un.equals(pw)){
msg="Hello"+un+"!your login is sucessful";
}else{
msg="hello"+un+"!your login failed";
}
res.setContentType("text/html");
PrintWriter out=res.getWriter();
System.out.println("<fontsize=6 color=red>"+msg+"<font>");
}
public void destroy(){
System.out.println("destroy() login servlet");
}
}
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16095
    
  21

"Narayan ks",

We don't have many rules here at the JavaRanch, but we do insist that you use your Real Name and not some sort of "handle" or obvious alias. If you're not sure about this, see
http://www.javaranch.com/name.jsp .

I make it a policy not to answer questions until people have their display names in order, but I will say that this is not a Tomcat problem. You have an error in your code which will fail on any J2EE server, not just Tomcat. And provided one more example why it's not a good idea to write your own login/security code.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
GeeCON Prague 2014
 
subject: http status 500 error in tomcat 6,when i try to run a simple login servlet for entering name & pwd