• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

HTTP Status 500 -

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 = "jdbc:odbc: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.
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ?


 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks

Yes i configured web.xml file.


yup next time i will be taking care of code tags.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 238
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please post web.xml.
 
sunil khandelwal
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
reply
    Bookmark Topic Watch Topic
  • New Topic