File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HTTP Status 500 -

 
sunil khandelwal
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64205
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
sunil khandelwal
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks

Yes i configured web.xml file.


yup next time i will be taking care of code tags.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 238
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please post web.xml.
 
sunil khandelwal
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks to all of u.

I got the solution.

This problem was coming because of wrong tomcat structure.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic