An error occurred at line: 7 in the jsp file: /Result.jsp
Generated servlet error: bad class file: D:Program FilesApache GroupTomcat 4.1webappstestWEB-INFclassesbeanclassesEmployee.class class file contains wrong class: Employee Please remove or make sure it appears in the correct subdirectory of the classpath. Employee emp1; ^ 1 error
at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:130) at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:293) at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:340) at org.apache.jasper.compiler.Compiler.compile(Compiler.java:352) at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:474) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:184) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643) at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:432) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:386) at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:530) at java.lang.Thread.run(Thread.java:536)
public void setEid(String Eid) { this.Eid=Eid; } public String getEid() { return Eid; } public void setEname(String Ename) { this.Ename=Ename; } public String getEname() { return Ename; } public void setEage(int Eid) { this.Eage=Eage; } public int getEge() { return Eage; } public void setEsalary(int Esalary) { this.Esalary=Esalary; } public int getEsalary() { return Esalary; } public void setEdesg(String Edesg) { this.Edesg=Edesg; } public String getEdesg() { return Edesg; } public void setEdept(String Edept) { this.Edept=Edept; } public String getEdept() { return Edept; }
public void setEdoj(Date Edoj) { this.Edoj=Edoj; } public Date getEdoj() { return Edoj; } } HTML file -------------------------------------------------------
MVC architecture Errors - Help
But i am getting the error as
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 7 in the jsp file: /Result.jsp
Generated servlet error:
[javac] Compiling 1 source file
D:Program FilesApache GroupTomcat 4.1workStandalonelocalhosttestResult_jsp.java:50: cannot access beanclasses.Employee
An error occurred at line: 7 in the jsp file: /Result.jsp
Generated servlet error:
bad class file: D:Program FilesApache GroupTomcat 4.1webappstestWEB-INFclassesbeanclassesEmployee.class
class file contains wrong class: Employee
Please remove or make sure it appears in the correct subdirectory of the classpath.
Employee emp1;
^
1 error
at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:130)
at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:293)
at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:340)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:352)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:474)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:184)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:432)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:386)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:530)
at java.lang.Thread.run(Thread.java:536)
--------------------------------------------------------------------------------
Apache Tomcat/4.1.18-LE-jdk14
Here is my code
Servlet
-------------------------------------------------------
import java.io.*;
import java.sql.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import beanclasses.*;
public class Controller extends HttpServlet
{
PrintWriter out;
private boolean found=false;
private HttpSession session=null;
private Connection con=null;
private String sourcepage,target;
public void init(ServletConfig config) throws ServletException
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:mvc");
}
catch(Exception e)
{
System.out.println("Exception1: " +e);
}
}
public void doPost(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
{
try
{
out=res.getWriter();
session=req.getSession(true);
sourcepage=req.getParameter("source");
if(sourcepage.equals("Login"))
{
ResultSet rs;
String id=req.getParameter("userid");
String pass=req.getParameter("password");
PreparedStatement ps=con.prepareStatement("SELECT *FROM Login WHERE UserId=? AND Password=?");
ps.setString(1,id);
ps.setString(2,pass);
rs=ps.executeQuery();
if(rs.next())
{
System.out.println("User Exists");
found=true;
}
if(found)
{
System.out.println("Entering Processing");
target="/Process.html";
System.out.println("Target is Process");
ps=con.prepareStatement("SELECT DISTINCT Eid FROM Emp");
rs=ps.executeQuery();
ArrayList list=new ArrayList();
while(rs.next())
{
list.add(rs.getString("Eid"));
}
session.setAttribute("EidDetails",list);
}
else
{
System.out.println("No Such User");
session.setAttribute("msg", new String("Invalid UserID/Password"));
target="/Login.jsp";
}
rs.close();
ps.close();
}
else if(sourcepage.equals("Search"))
{
target="/Result.jsp";
String id=req.getParameter("Eid");
PreparedStatement ps;
ResultSet rs;
ps=con.prepareStatement("SELECT * FROM Emp WHERE Eid=?");
ps.setString(1, id);
rs=ps.executeQuery();
ArrayList list=new ArrayList();
while(rs.next())
{
Employee emp=new Employee();
emp.setEid(rs.getString("Eid"));
emp.setEname(rs.getString("Ename"));
emp.setEage(rs.getInt("Eage"));
emp.setEsalary(rs.getInt("Esalary"));
emp.setEdesg(rs.getString("Edesg"));
emp.setEdept(rs.getString("Edept"));
emp.setEdoj(rs.getDate("Edoj"));
list.add(emp);
}
session.setAttribute("SearchResults",list);
rs.close();
}
System.out.println("Diverting To Page: " +target);
RequestDispatcher rd=req.getRequestDispatcher(target);
rd.forward(req,res);
}
catch(SQLException se)
{
System.out.println("Exception2: " +se);
}
catch(ServletException x)
{
System.out.println("Exception3: " +x);
}
catch(IOException e)
{
System.out.println("Exception4: " +e);
}
catch(Exception ex)
{
System.out.println("Exception5: " +ex);
}
}
public void destroy()
{
try
{
con.close();
}
catch(SQLException se)
{
System.out.println("Exception6: " +se);
}
}
}
-------------------------------------------------------
Bean
-------------------------------------------------------
import java.util.*;
public class Employee implements java.io.Serializable
{
String Eid;
String Ename;
int Eage;
int Esalary;
String Edesg;
String Edept;
Date Edoj;
public Employee()
{
}
public void setEid(String Eid)
{
this.Eid=Eid;
}
public String getEid()
{
return Eid;
}
public void setEname(String Ename)
{
this.Ename=Ename;
}
public String getEname()
{
return Ename;
}
public void setEage(int Eid)
{
this.Eage=Eage;
}
public int getEge()
{
return Eage;
}
public void setEsalary(int Esalary)
{
this.Esalary=Esalary;
}
public int getEsalary()
{
return Esalary;
}
public void setEdesg(String Edesg)
{
this.Edesg=Edesg;
}
public String getEdesg()
{
return Edesg;
}
public void setEdept(String Edept)
{
this.Edept=Edept;
}
public String getEdept()
{
return Edept;
}
public void setEdoj(Date Edoj)
{
this.Edoj=Edoj;
}
public Date getEdoj()
{
return Edoj;
}
}
HTML file
-------------------------------------------------------
-------------------------------------------------------
JSP file(Search.jsp)
-------------------------------------------------------
<%@ page language="java" import="java.util.ArrayList" %>
-------------------------------------------------------
JSP file(Result.jsp)
-------------------------------------------------------
<%@ page language="java" import="java.util.ArrayList" %>
<%@ page import="beanclasses.*" %>
<%
ArrayList list=(ArrayList)session.getAttribute("SearchResults");
Employee emp1;
%>
Search Results
<%
}
else
{
for(int i=0;i
emp1=(Employee)list.get(i);
%>
This Question is not yet answered!
Related Answered Questions
Related Open Questions
Latest News
It looks like you are using an AD Blocker!
Please Turn OFF your ad blocker
- OR -
LOGIN to continue using GeekInterview website.
Disable
Ad Blocker
Learn More
Login
GeekInterview
Login
Create your
GeekInterview account
Signup
Continue Reading after Disabling
Refresh