File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes unable to compile class for JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "unable to compile class for JSP" Watch "unable to compile class for JSP" New topic
Author

unable to compile class for JSP

derrick tan
Greenhorn

Joined: Jul 29, 2006
Posts: 11
Hi all,

i have facing some compilation problem...Actually now i was new in jsp and java and this is my first time using eclipse to develop a requisition system for my intership at a company... i have compile the existing class file into a jar file already... i also already import it, and doesn't saw any problem for my jsp page... i mean in my jsp page i have import the some of the class file that needed to process my jsp page and i do not saw any problem(red underline) for my coding... but after i still can't run my jsp page... because the error msg is can't compile the jsp...
so can anyone tell me what should do... thanks in advance...
[ October 18, 2006: Message edited by: Bear Bibeault ]

Best regards,<br />derrick<br />~Thanks in advance~
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Please send the full error message and trace


[My Blog]
All roads lead to JavaRanch
derrick tan
Greenhorn

Joined: Jul 29, 2006
Posts: 11
Sir, here is my error msg... I don't understand what is "only a type can be import", does it means there can only be 1 package ? Thank you, sir


Oct 20, 2006 11:54:32 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: Unable to compile class for JSP

Generated servlet error:
Only a type can be imported. bgoc.webaccs.UserInfo resolves to a package

Generated servlet error:
Only a type can be imported. bgoc.def.CommonQuery resolves to a package

Generated servlet error:
Only a type can be imported. bgoc.def.DfdtypQuery resolves to a package

Generated servlet error:
Only a type can be imported. bgoc.authorize.AuthMeta resolves to a package

An error occurred at line: 11 in the jsp file: /dfdtyp_inq.jsp
Generated servlet error:
UserInfo cannot be resolved to a type

An error occurred at line: 11 in the jsp file: /dfdtyp_inq.jsp
Generated servlet error:
UserInfo cannot be resolved to a type

An error occurred at line: 11 in the jsp file: /dfdtyp_inq.jsp
Generated servlet error:
UserInfo cannot be resolved to a type

An error occurred at line: 11 in the jsp file: /dfdtyp_inq.jsp
Generated servlet error:
AuthMeta.APPLICATION_CODE cannot be resolved to a type

An error occurred at line: 52 in the jsp file: /dfdtyp_inq.jsp
Generated servlet error:
DfdtypQuery cannot be resolved to a type

An error occurred at line: 52 in the jsp file: /dfdtyp_inq.jsp
Generated servlet error:
DfdtypQuery cannot be resolved to a type

An error occurred at line: 52 in the jsp file: /dfdtyp_inq.jsp
Generated servlet error:
CommonQuery cannot be resolved


at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:414)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:297)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:303)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60046
    
  65

It means your import statements are incorrect. They follow the same rules as in Java.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
derrick tan
Greenhorn

Joined: Jul 29, 2006
Posts: 11
Sir,

Im using Eclipse to write code. When I remove import statement, it show error (red underline) on certain tags that can't read the the import. I know this is normal, because i have already remove the import statement. But when i put back the import statement then all the error(red underlines) disappear, which means my jsp page have no error and can read the import page, right? This really confusing


Thank you sir
Derrick
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60046
    
  65

Who are you going to believe? The IDE or the JSP engine?

Regardless of what the IDE tells you, if your pages don't work when deployed, they're wrong.

With regards to import statements, you must either import a class or an entire packge. To do the latter, be sure to end the import with ".*".

Or better yet, join the rest of us in 2006 and stop putting scriplets on your pages.
derrick tan
Greenhorn

Joined: Jul 29, 2006
Posts: 11
Sir,

I already import all the packages that i want to use and this is a standard package that my supervisor gave me, can it be the package already corrupted?
Sir, im new to JSP, i don't get what you mean
"join the rest of us in 2006 and stop putting scriplets on your pages"

Please forgive me if I offence you


Thank you
vishwanath nadimpally
Ranch Hand

Joined: Jan 25, 2005
Posts: 116

derrick tan:
I already import all the packages that i want to use and this is a standard package that my supervisor gave

what do you mean by 'this is a standard package. There are no standard packages in java. They are not like zip files or jar files that you can add one to another one.

You would have to import all packages needed with separate import statements.
Also, if you are using many classes from the same package you can do so by using the '*' like import com.example.*;
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1506
As others have said, there is something wrong with your import statemet. Why don't you post the exact import statement.


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
derrick tan
Greenhorn

Joined: Jul 29, 2006
Posts: 11
<%@page import="bgoc.webaccs.UserInfo"%>
<%@page import="bgoc.authorize.AuthMeta"%>
<%@page import="bgoc.com.converter.ConvertChar"%>
<% final String contextPath = request.getContextPath();
UserInfo uif = (UserInfo) session.getAttribute("UserInfo");
if (uif == null) {
response.sendRedirect(contextPath);
return;
} else if(!uif.validateNoChange(request)){
response.sendRedirect(contextPath + "/errorPages/MultiSessionError.jsp");
return;
} else if (!uif.chkPage("dfdtyp_add.jsp", "dfdtyp_inq.jsp")) {
response.sendRedirect(contextPath);
return;
}
uif.setAppl(AuthMeta.APPLICATION_CODE);
%>


This is my coding with the import statement and my supervisor told me that i should import all the necessary class file in this package, because she already have other program using this package and i just need to create other jsp form to import the process in this package, that why i called it as "standard package"...
derrick tan
Greenhorn

Joined: Jul 29, 2006
Posts: 11
Hi... Can anyone tell me what might be the possible cause the error of "only a type can be imported"?

Thank you...
derrick tan
Greenhorn

Joined: Jul 29, 2006
Posts: 11
Is it i need to used java file to run my jsp program, because i just have class file which already compile into jar file and this jar file is i get from my supervisor one! Every time i compile my program i have this problem.. i don't know is it i need the java file in order to run my jsp program... It is because i got a sample from my supervisor and the program can successfully ran at my supervisor's computer, but when put into my computer. It come out this kind of error, so can anyone tell.

Thanks you!!!
Good Luck!!!
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Where are you putting the jar file?


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: unable to compile class for JSP
 
Similar Threads
a simple JSP problem
ARRRGGGGHHH - Stupid Javabeans - Again! :(
Problem with recognizing the class files
Why is Runtime.getRuntime().exec() not working in JSP?
JSP strange problem