Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

unable to compile class for JSP

 
derrick tan
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please send the full error message and trace
 
derrick tan
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It means your import statements are incorrect. They follow the same rules as in Java.
 
derrick tan
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As others have said, there is something wrong with your import statemet. Why don't you post the exact import statement.
 
derrick tan
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<%@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
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where are you putting the jar file?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic