File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes EL function example from Hanumant Deshmukh Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "EL function example from Hanumant Deshmukh" Watch "EL function example from Hanumant Deshmukh" New topic
Author

EL function example from Hanumant Deshmukh

saima kanwal
Ranch Hand

Joined: Oct 05, 2009
Posts: 148
I m trying to do the example of EL from SCWCD Hanumant Deshmukh with litt;e modification. I tried it using a simple web app. I am unable to get the response. I am getting this error:

HTTP Status 500

org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: 13 in the generated java file
StrMethods cannot be resolved to a type

Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:439)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:334)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:312)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:299)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:589)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
TestELServlet.doGet(TestELServlet.java:10)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

note The full stack trace of the root cause is available in the Apache Tomcat/6.0.24 logs.

My index.html is :



My servlet code is :



my method java file is:



My .tld file is:



and my result.jsp is :



Can anyone tell me what mistake I am making and why am I getting this error?


SCJP 6.0 (86%) SCWCD 5 (94%)
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9319
    
  17

Putting Servlet or Tag or EL function classes in default package is not a very good idea. Add a package statement to your StrMethods class, use the fully qualified name of the class in the tld file and then try again (also put your servlet in a package as it might create problems in the future)...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
saima kanwal
Ranch Hand

Joined: Oct 05, 2009
Posts: 148
Thanks Ankit. It is working now , after putting these files in a package (as suggested by you).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: EL function example from Hanumant Deshmukh