This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
narayan ks
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Pie
Posts: 18152
52
Android Eclipse IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic