Importing user-defined class in a JSP page

2005-06-09 Thread uttam.g.dubal
I'm new to programming in JSP/Tomcat. I am kinda held back with the
following simple situation.  I have database connection class that I'm
trying to import in my jsp file with no success so far (ChangePassword).
I am compiling with JDK1.4.2.08.
 
My JSP page is in 
$CATALINA_HOME/webapps/mywebapp/
 
I do have a web.xml file that is correctly configured with passwords and
values to allow the application to connect to the user directory.  This
is the stack trace of the error:
org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 85 in the jsp file: /changepw.jsp
Generated servlet error:
Invalid argument to operation ++/--



org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHa
ndler.java:84)

org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.ja
va:328)

org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:39
7)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:288)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:267)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:255)

org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.ja
va:556)

org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.ja
va:293)

org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)

org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
Any ideas how to import a user-defined class in JSP, I mean where to
place the class file and is there anyother environment variable to set?
I read somewhere that if you are using jdk 1.4 and above, you need to
have package name for classes.  It said to Put your webappname class in
a package, compile it and then import it like the following in your JSP
file:  %@ page import=packagename.WebAppName% 

Again, I am new to all of this so could you possibly help me with the
issue as well as helping me to understand the potential fix as outlined
above?  I would really appreciate any help you can provide.
 
Thanks


This message is for the designated recipient only and may contain privileged, 
proprietary, or otherwise private information.  If you have received it in 
error, please notify the sender immediately and delete the original.  Any other 
use of the email by you is prohibited.


Re: Importing user-defined class in a JSP page

2005-06-09 Thread delbd
Supposing your class looks like the following:

package com.mycompany.mywebapp
public class MyClass {
}


then you need the following import directive 
%@ page import=com.mycompany.mywebapp.MyClass%
or
%@ page import=com.mycompany.mywebapp.*%

Please note, i see you have your error at line 85, don't forget your %@ page 
import=... % directives must be at the top of the jps, not in the code

Also, compiled class must be either in 
WEB-INF/classes/com/mycompany/mywebapp/MyClass.class
or in a .jar file located in WEB-IF/lib/*.jar

Le Jeudi 9 Juin 2005 15:50, [EMAIL PROTECTED] a écrit :
 I'm new to programming in JSP/Tomcat. I am kinda held back with the
 following simple situation.  I have database connection class that I'm
 trying to import in my jsp file with no success so far (ChangePassword).
 I am compiling with JDK1.4.2.08.

 My JSP page is in
 $CATALINA_HOME/webapps/mywebapp/

 I do have a web.xml file that is correctly configured with passwords and
 values to allow the application to connect to the user directory.  This
 is the stack trace of the error:
 org.apache.jasper.JasperException: Unable to compile class for JSP

 An error occurred at line: 85 in the jsp file: /changepw.jsp
 Generated servlet error:
 Invalid argument to operation ++/--



 org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHa
 ndler.java:84)

 org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.ja
 va:328)

 org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:39
 7)
   org.apache.jasper.compiler.Compiler.compile(Compiler.java:288)
   org.apache.jasper.compiler.Compiler.compile(Compiler.java:267)
   org.apache.jasper.compiler.Compiler.compile(Compiler.java:255)

 org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.ja
 va:556)

 org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.ja
 va:293)

 org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)

 org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
 Any ideas how to import a user-defined class in JSP, I mean where to
 place the class file and is there anyother environment variable to set?
 I read somewhere that if you are using jdk 1.4 and above, you need to
 have package name for classes.  It said to Put your webappname class in
 a package, compile it and then import it like the following in your JSP
 file:  %@ page import=packagename.WebAppName%

 Again, I am new to all of this so could you possibly help me with the
 issue as well as helping me to understand the potential fix as outlined
 above?  I would really appreciate any help you can provide.

 Thanks


 This message is for the designated recipient only and may contain
 privileged, proprietary, or otherwise private information.  If you have
 received it in error, please notify the sender immediately and delete the
 original.  Any other use of the email by you is prohibited.

-- 
David Delbecq
Royal Meteorological Institute of Belgium

-
Is there life after /sbin/halt -p?

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]