aspose file tools*
The moose likes Servlets and the fly likes HTTP Status 500 - Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "HTTP Status 500 - " Watch "HTTP Status 500 - " New topic
Author

HTTP Status 500 -

sunil khandelwal
Greenhorn

Joined: Aug 02, 2010
Posts: 5
Hi,

I am new to servlet.

when i run servlet then it gives this error.


HTTP Status 500 -

type Exception report

message

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

exception

javax.servlet.ServletException: Class GetData is not a Servlet
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:843)
org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:640)
org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1293)
java.lang.Thread.run(Thread.java:595)

root cause

java.lang.ClassCastException: GetData
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:843)
org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:640)
org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1293)
java.lang.Thread.run(Thread.java:595)

note The full stack trace of the root cause is available in the Apache Tomcat/5.5.30 logs.
Apache Tomcat/5.5.30

and my code is:-


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

import java.sql.*;

import java .io.*;


public class GetData extends HttpServlet
{
/**
*
*/
private static final long serialVersionUID = 1L;

public void doPost(HttpServletRequest request,HttpServletResponse response) throws IOException,ServletException
{
response.setContentType("text/html" );
PrintWriter out = response.getWriter();
String names[] = new String[5];
names[0] = request.getParameter("aa1");
names[1] = request.getParameter("aa2");
names[2] = request.getParameter("aa3");
names[3] = request.getParameter("aa4");
names[4] = request.getParameter("aa5");

/*try {
Database_connection(request);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
RequestDispatcher dp = request.getRequestDispatcher("../../sunil.jsp");
dp.forward(request,response);*/
}

/*private void Database_connection(HttpServletRequest request) throws ClassNotFoundException, SQLException {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String db = "jdbcdbc:name";
Connection connection = DriverManager.getConnection(db);
String s = "INSERT INTO name_table (no , tittle) VALUES (?,?)";
PreparedStatement preparedstatement = connection.prepareStatement(s);
String no = request.getParameter("aa1");
String tittle = request.getParameter("aa2");
preparedstatement.setString(1, no);
preparedstatement.setString(2, tittle);


preparedstatement.executeUpdate();
preparedstatement.close();
}*/
}



please give me the solution of this problem.

Thanks in advance.
SbhargavS Surimenu
Greenhorn

Joined: Mar 09, 2010
Posts: 4
With my knowledge Every class that extends GenericSerlvet or HttpServlet should be treated as a servelt by the server.
I have reviewed your servelt, but I didnt see any problems with your servlet. Have you configured your servelt in web.xml ?


Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61436
    
  67

Please be sure to use code tags when posting code to the forums. Unformatted or unindented code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please click this link ⇒ UseCodeTags ⇐ for more information.

Properly indented and formatted code greatly increases the probability that your question will get quicker, better answers.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
sunil khandelwal
Greenhorn

Joined: Aug 02, 2010
Posts: 5
Thanks

Yes i configured web.xml file.


yup next time i will be taking care of code tags.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

sunil khandelwal wrote:Yes i configured web.xml file.

We can't see it, though.

Please edit your post to include code tags.

Also, servlets must not be in the default package.
Mathew Lee
Ranch Hand

Joined: Jun 08, 2009
Posts: 238
Please post web.xml.
sunil khandelwal
Greenhorn

Joined: Aug 02, 2010
Posts: 5
thanks to all of u.

I got the solution.

This problem was coming because of wrong tomcat structure.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: HTTP Status 500 -