JSP page not compiling

K

KK

HEllo Everyone,
i am creating a simple jsp and servlet application..i am using
J2EE1.4
application server.
When i am trying to run my JSP application i am encountered with the
following error:
I even copied the tools.jar file to the sun->j2ee1.4->lib folder but
no response.
----------------------
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
No Java compiler was found to compile the generated source for the
JSP.
This can usually be solved by copying manually $JAVA_HOME/lib/
tools.jar from the JDK
to the common/lib directory of the Tomcat server, followed by a
Tomcat
restart.
If using an alternate Java compiler, please check its installation
and
access path.
org.apache.jasper.compiler.DefaultErrorHandler.javacError
(DefaultErrorHandler.java:127)
org.apache.jasper.compiler.ErrorDispatcher.javacError
(ErrorDispatcher.java:348)
org.apache.jasper.compiler.Compiler.generateClass
(Compiler.java:424)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:
464)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:
448)
org.apache.jasper.JspCompilationContext.compile
(JspCompilationContext.java:551)
org.apache.jasper.servlet.JspServletWrapper.service
(JspServletWrapper.java:300)
org.apache.jasper.servlet.JspServlet.serviceJspFile
(JspServlet.java:
301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:
248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:324)
org.apache.catalina.security.SecurityUtil$1.run
(SecurityUtil.java:
284)
java.security.AccessController.doPrivileged(Native Method)
javax.security.auth.Subject.doAsPrivileged(Subject.java:500)
org.apache.catalina.security.SecurityUtil.execute
(SecurityUtil.java:
306)
org.apache.catalina.security.SecurityUtil.doAsPrivilege
(SecurityUtil.java:200)
-------------------
my jsp bean code is as following :
-----
<%@ page import = "java.util.*" %>
<%! String username;
boolean check;
%>
<%
username = request.getParameter("uname");
%>
<jsp:useBean id="ob" class="MainCheck" />
<jsp:setProperty name="ob" property="userName" value="<
%=username
%>" />
<%
check = ob.check();
if(check)
{
%>
<h2>User Exists</h2>
<%
}
else
{
%>
<h2>User Doesnt Exists </h2>
<%
}
%>
 
H

Holmbrew

I would try these things:

1. Is $JAVA_HOME actually a set env var?
2. Make sure your $JAVA_HOME is actually ../sun/j2ee1.4/lib
3. Looks like you are using Tomcat. You could probably put the
tools.jar in Tomcats lib directory.

-Jason
 
K

KK

well, all the paths are set properly, i chcked them again
i was using j2ee1.4 server, the above error mentioned is when j2ee1.4
server is running, but after posting this problem, i switched to
tomcat too. It gives the following error:

rg.apache.jasper.JasperException: /KK App/Maincheck.jsp(13,0) The
value for the useBean class attribute com.Main is invalid.
org.apache.jasper.compiler.DefaultErrorHandler.jspError
(DefaultErrorHandler.java:39)
org.apache.jasper.compiler.ErrorDispatcher.dispatch
(ErrorDispatcher.java:405)
org.apache.jasper.compiler.ErrorDispatcher.jspError
(ErrorDispatcher.java:146)
org.apache.jasper.compiler.Generator$GenerateVisitor.visit
(Generator.java:1223)
org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1116)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2213)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2219)
org.apache.jasper.compiler.Node$Root.accept(Node.java:456)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
org.apache.jasper.compiler.Generator.generate(Generator.java:3284)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:189)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:267)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:255)
org.apache.jasper.JspCompilationContext.compile
(JspCompilationContext.java:556)
org.apache.jasper.servlet.JspServletWrapper.service
(JspServletWrapper.java:293)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:
314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
---

I just wonder why it is so..
I have checked my class files and all but its not wrking.

the class file Main.class code is:


package com;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import javax.servlet.http.HttpServlet;

public class Main extends HttpServlet
{
String userName;

public String getUserName()
{
return userName;
}

public void setUserName(String userName)
{
this.userName = userName;
}

public boolean check() throws Exception
{
Connection c = getConnection();
ResultSet rs = getResultSet(c);
if(rs.next())
{
return true;
}
else
{
return false;
}
}

private ResultSet getResultSet(Connection c) throws SQLException {
Statement st = c.createStatement();
ResultSet rs = st.executeQuery("Select * from user where
uname="+userName);
return rs;
}

private Connection getConnection() throws ClassNotFoundException,
SQLException {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c = DriverManager.getConnection("jdbc:eek:dbc:test","","");
return c;
}

}
 
L

Lew

Holmbrew said:
I would try these things:

1. Is $JAVA_HOME actually a set env var?
2. Make sure your $JAVA_HOME is actually ../sun/j2ee1.4/lib

Wouldn't that be the directory for a J2EE installation? You want
JAVA_HOME to indicate a JDK installation, not a J2EE / Java EE
installation.

Please do not top-post.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,039
Messages
2,570,375
Members
47,020
Latest member
anuradha

Latest Threads

Top