sunil khandelwal

Greenhorn
+ Follow
since Aug 02, 2010
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by sunil khandelwal

k.

ya next time i will do.

by ASAP my means as soon as possible.
13 years ago
thanks to all of u.

I got the solution.

This problem was coming because of wrong tomcat structure.
13 years ago
Hi,

I am very new to servlet.

I made a class to connect servlet to database bt i m getting this error.




my servlet class GetData.java is:-


and my database connection class Mysql_connection.java code is :-


please tell me solution ASAP


Thanks in advance.>
13 years ago
Thanks

Yes i configured web.xml file.


yup next time i will be taking care of code tags.
13 years ago
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.
13 years ago