Importing classes for a jsp
Hi,
I'm trying to get a jsp working. This is part of the code of test.jsp:
<%@page import="First, Second" %>
<HTML>
<HEAD>
<TITLE>JSP Example 3</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFCC">
<CENTER>
<H2>Date and Time</H2>
First.hello() is: <% First.hello(); %>
Second.hi() is: <% Second.hi(); %>
</CENTER>
</BODY>
</HTML>This is the output of the compilation in Tomcat:
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 6 in the generated java file
The import First cannot be resolved
An error occurred at line: 7 in the generated java file
The import Second cannot be resolved
An error occurred at line: 9 in the jsp file: /date3.jsp
First cannot be resolved
6: <BODY BGCOLOR="#FFFFCC">
7: <CENTER>
8: <H2>Date and Time</H2>
9: First.hello() is: <% First.hello(); %>
10: Second.hi() is: <% Second.hi(); %>
11: </CENTER>
12: </BODY>First.class and Second.class are the two files who share the directory with test.jsp
I'm flabergasted with this error. As I am using very basic code for this example you would think it works (or is this error one of the NullPointerException kind?).
Abel
Edited by: Abel on Dec 12, 2007 6:21 AM
Changed to a more basic type of example
I found the answer myself ~:-).
Add the files you want to import to a jar file
* To be more precise, in the directory I have the jsp, I created first a directory WEB-INF, and in that directory created a directory lib, and finally created a directory test. I moved the two Java files to the test directory. I changed the Java files (added a package statement). So the configuration is now:
<%@page import="test.*" %>
<HTML>
<HEAD>
<TITLE>JSP Example 3</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFCC">
<CENTER>
<H2>Date and Time</H2>
<%
First first = new First();
out.println ("First says: " + first.hello());
%>
</CENTER>
</BODY>
</HTML>And the two java files:
package test;
public class First {
public String hello() {
return ("Hello from First");
package test;
public class Second {
public String hi() {
return ("Hi from Second");
}And finally I added the two classes I got after compilation to a jar file in the WEB-INF\lib directory:
jar -cvf test.jar test\First.class test\Second.classI just explain what I did wrong, as I saw many comparable posts without an answer. And this basic problem can keep you away from the real work.
Abel.
Similar Messages
-
I have created a class file called BindListener.java and put it in my root directory in my web module. I cannot however get the import statement for the jsp right, my root directory is called JBuilder. I have tried putting it in the WEB-INF classes folder also but still when I try to execute thr jsp it dosent work.
There is no package declared in the classs file and it does not extend any other class, however it implements the HttpSessionBindingListener interface.
I can call servlets from my JSP in the WEB-INF classes dir using /JBuilder/ServletName
I am mondo confused please helpI have created a class file called BindListener.java
and put it in my root directory in my web module. I
cannot however get the import statement for the jsp
right, my root directory is called JBuilder. I have
tried putting it in the WEB-INF classes folder also
but still when I try to execute thr jsp it dosent
work.
There is no package declared in the classs file and
it does not extend any other class, however it
implements the HttpSessionBindingListener interface.You have to put the class in a package, then put the .class file in a package directory under WEB-INF/classes. So for example:
package beans;
public class BindListener ...
//goes into this directory structure
<APP_ROOT>/
*.jsp
WEB-INF/
web.xml
classes/
beans/
BindListener.class
//And is imported into your JSP using one of the following
// -- EITHER --
<%@ page import="beans.BindListener" %>
<%
BindListener bl = new BindListener();
%>
// -- OR --
<jsp:useBean id="bl" class="beans.BindingListener"/>>
I can call servlets from my JSP in the WEB-INF
classes dir using /JBuilder/ServletName
I am mondo confused please help -
Importing class in a jsp using Tomcat
Hello All,
Using Tomcat:
I have class here:
examples/WEB-INF/classes/ package/myclass.class
I have a .jsp here:
examples/JSPFolder/myjspfile.jsp
I want to import the class into the jsp.
I have tried the following combinations of importy lines based on previous posts on these boards and each have failed with same error:
Unable to load class for JSP
<%@ page import="myclass" %>
<%@ page import="myclass.*" %>
<%@ page import="package.myclass" %>
<%@ page import="package.myclass.*" %>
<%@ page import="WEB-INF/classes/package/myclass%>
I have seen a number of posts for this same problem, and have tried those solutions as well, but none work. I am sure that this is simply a problem of finding the right directory, as I can successfully run the .jsp file iwhen I remove the import line.
Can someone please help?There is a folder for shared packages
tomcat_root\lib; or
tomcat_root\common
also most versions have a lib or common folder for each webapp for packages that are not to be shared.
tomcat_root\webapps\appname\web-inf\lib
Agreed that it is strange to allow servlets to import from the classes foler but not JSPs. It should make no difference but it is convension to place single classes in the same folder as the app's directory and packages (especially jar's) in the lib directory. -
Error when I import classes using directive JSP page
Hi all!
I have installed JDeveloper 11g (11.1.1.3.0)
My applications are located in the C:\dir (JDEV_USER_DIR = C:\dir)
I Created application "Appliation1". In it i created 2 projects (Project1, in it beans session entity and other java classes; Project2, in it JSP).
I want import classes from Project1 to Project2 using next directive:
<%@ page contentType="text/html;charset=windows-1252"
import="project1.*"%>
so in Project properties of Project2 set the way to classes in Project1.
When i run JSP an error occurred:
Error(4,9): The import project1 cannot be resolved
Maybe i'm not set correctly the way to the classes
Thanks in advance.angelr, thanks, it helped me)
In jdeveloper 10g i set address in Project Properties->Libraries and Classpath->Add JAR/Directory;
and set the way to my classes;
and it worked.
in the 11 version seems different -
Using an imported class in a JSP file
When you import a class you wrote into a JSP file, is there a way to submit values from forms to the entire class, or can you only use the methods within the class??
When you import a class you wrote into a JSP file, is
there a way to submit values from forms to the entire
class, or can you only use the methods within the
class??Yes, there is a way in JSP. You can use,
<jsp:useBean id="your_bean_id" scope="page or request etc" class="your_class">
<jsp:setProperty name="your_bean_id" property="*"/>
</jsp:useBean>
So, <jsp:setProperty> sets all the values inside your request object into the bean, if the class is having the properties (variables) with same name as of request object's parameters. You must have coded set method for all the properties whatever you want your jsp to set the values in the bean.
if your request is .../yourjsp?name=xxxx&age=25
then <jsp:setProperty> method will set the name and age inside bean if you have,
public class YourBean {
String name;
int age;
public void setName(String name) {
this.name=name;
public void setAge(int age) {
this.age=age;
Hope this helps.
Sudha -
Importing .class file into jsp file
i am unable to import a .class file into my .jsp file
please give me the correct method to import and also tell me where to deploy the .class filei am unable to import a .class file into my .jsp
file
please give me the correct method to import and also
tell me where to deploy the .class filehttp://www.apl.jhu.edu/~hall/java/Servlet-Tutorial/Servlet-Tutorial-JSP.html#Section5 -
Importing classes that implement jsp tags
I was making a custom JSP tag library. The tag functionality was implemented in
a class called, lets cay ClassA. I made the tld file and put it under the WEB-INF
directory. The class which implemented the functionality was placed under WEB-INF/classes
directory. I had the imported the tag library using the taglib directive. I was
getting an error which said "cannot resolve symbol". But when I in the JSP file
I imported the class file which implemented the taglib functionality the error
vanished. Is it necessary to import the class files even if the taglib is imported.
The documentation does not say so. Or is there some configuration I have to make.
I think was a side effect of the .jsp changing redeploys the web app in 6.0.
When the web app was redeployed your directory structure was reread and thus
it found your .tld.
Sam
"bbaby" <[email protected]> wrote in message
news:3b422db7$[email protected]..
>
> I was making a custom JSP tag library. The tag functionality was
implemented in
> a class called, lets cay ClassA. I made the tld file and put it under the
WEB-INF
> directory. The class which implemented the functionality was placed under
WEB-INF/classes
> directory. I had the imported the tag library using the taglib directive.
I was
> getting an error which said "cannot resolve symbol". But when I in the JSP
file
> I imported the class file which implemented the taglib functionality the
error
> vanished. Is it necessary to import the class files even if the taglib is
imported.
> The documentation does not say so. Or is there some configuration I have
to make.
>
>
-
JSP implementation class for a JSP Page
Hello,
It is very important for me to know ...
- Do you consider that a JSP developer should know that each JSP Page becomes at run-time a Java Servlet ? And int the way that the Java code you have wrote in the JSP Page is dispatched in the declaration of this servlet ?
He should know how the Java code generated by the server looks like ?
Thank you all for your answers.
AdrianaEverybody's going to have their own opinion on this - here's my 2 cents.
Theoretically, there are at least two roles here.
#1. An expert in HTML, graphic layout, user interface etc.
#2. A programmer who understands the technical infrastructure - Java, beans, servlets, database connections etc.
In the perfect world, Role #1 would build JSPs and would not need to understand Java or the technical architecture. The JSPs would act as templates and not contain any Java code (e.g. scriptlets). Role #2 would build custom tags and beans for use in the JSPs.
To answer your question, Role #1 should not understand how JSPs are translated to servlets, but Role #2 should.
In reality, the two roles are often filled by the same person, usually a programmer who may introduce Java elements into the JSP. Once this occurs, then the JSP has become a program rather than a template and knowledge of its translation to servlets is necessary for debugging. -
How to keep the generated java classes for compiled jsp in WL9.2 Workshop
Hi all,
<p>
It should be a very simple question for most of you, however, it seems a bit tricky to me: how to configure the Weblogic 9.2 workshop so that we could keep the generated java files for the compiled jsp when we ran the application within WL 9.2 workshop?
<p>
I try some configurations, but not working. Also, where are the generated java files stored?
<p>
Thanks for the help!
<p>
Agnes
Edited by wingagnes at 03/21/2008 7:51 AMHi yzeng,
<p>
Thanks for the reply. If I change the jsp-descriptor into the following:
<p>
<jsp-descriptor>
<p>
<keepgenerated>true</keepgenerated>
<p>
<working-dir>D:\temp\golGenerated</working-dir>
<p>
<debug>true</debug>
<p>
</jsp-descriptor>
<p>
I will get the following error message:
<p>
cvs-complex-type.2.3.d:Invalid content was found starting with element 'precompile'. No child element is expected at this point.
<p>
Thanks,
<p>
Agnes -
Import class for getOANLSServcies()
In order to use the getOANLSServcies() method in a program, what import statement must be added?
I have a field defined as a string but it holds numerical data that I would like to format as currency.
I have tried a lot of suggestions, none worked without causing "the table cannot be sorted..." error.
So I want to try the getOANLSServcies(). Any suggestions?
Edited by: user5500620 on Nov 19, 2009 8:22 AMimport oracle.apps.fnd.framework.OANLSServices;
--Prasanna -
Unable to compile class for JSP: import ...
Hi everybody!
I've tried to change from Servlet to JSP. The Servlet used a package und compiled fine under NB 4.1.
When the JSP is compiled on the Server (Sun Java System Application Server Platform Edition 8 2004Q4 Beta) the following error occurs:
org.apache.jasper.JasperException: Unable to compile class for JSP
Generated servlet error:
[javac] D:\Programme\Sun\AppServer\domains\domain1\generated\jsp\j2ee-modules\NR_Java4Web1\org\apache\jsp\DisplayingDatabaseRecords_jsp.java:44: illegal start of expression
[javac] import de.conus.util.DBUtil.*
[javac] ^
Do I have to place the classfile manually on the server?
Thanks for your help,
MichaelAll import-statements where of the same kind. I had to place trhe classfiles
at the application server under lib\classes. Now it works
Thanks -
Unable to compile class for JSP
Please can anyone help me to solve this.
Actually,this is the condition.
In my db,there is a table called UserPassword, which has 4
fields(empNo,UserName,password,level). Now I want to do these things:
When the user submits the data to create a new account via HTML form, it submits the data to the file called CreateAcc.jsp. In this file it perform some logic,here are they.
1)To check the empNo,if it is already exist in the DB,
if empNo =exist then display error.(record already exist)
if empNo =notexist then do task 2).
2)check the UserName,if it is already exist in the db,
if UserName=exist then display error.(because it's a primary key)
if UserName=notexist then do task 3).
3)Create a new user account and save it to the db.
To do these tasks,I never create a new objects for the tasks 1) and 2).
only for task 3)create an object.
Is it the right way?
Here is the file CreateAcc.jsp
<%@ page language="java" %>
<%@ page import="core.UserAccManager" %>
<%@ page import="data.UserPassword" %>
<jsp:useBean id="UserAccManager" class="core.UserAccManager" scope="session"/>
<jsp:setProperty name="UserAccManager" property="*"/>
<jsp:useBean id="UserPassword" class="data.UserPassword" scope="session"/>
<jsp:setProperty name="UserPassword" property="*"/>
<%
String nextPage ="MainForm.jsp";
if(UserPassword.verifyEmpno()){
if(UserPassword.verifyUsername()){
if(UserPassword.createAcc()) nextPage ="MsgAcc.jsp";
}else{
nextPage="UserNameExist.jsp";
else{
nextPage="UserAccError.jsp";
%>
<jsp:forward page="<%=nextPage%>"/>The directory structure:
UserPassword.java- F:/Project/core/data/UserPassword.java
UserAccManager.java - F:/Project/core/UserAccManager.java
Now both are compiling.I put the class files into the TOMCAT,as follows.
UserAccManager.class - webapps/mySystemName/WEB-INF/classes/core/
UserPassword.class - webapps/mySystemName/WEB-INF/classes/core/data/
Here is the full code of the file UserAccManager.java.
package core; //Is this right?
import data.UserPassword; //Is this right?
import java.io.*;
import java.sql.*;
import java.util.*;
import javax.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
public final class UserAccManager{
private static final String DRIVER = "com.mysql.jdbc.Driver";
private static final String URL = "jdbc:mysql://localhost:3306/superfine";
private static Connection connection;
private static PreparedStatement pstmt1;
private static PreparedStatement pstmt2;
private static PreparedStatement pstmt3;
private UserAccManager(){
// Initializes the connection and statements
public static void initConnection() {
if (connection == null) {
try {
String sql;
// Open the database
Class.forName(DRIVER).newInstance();
connection = DriverManager.getConnection(URL);
// Prepare the statements
sql = "SELECT * FROM UserPassword where empNo= ?";
pstmt1 = connection.prepareStatement(sql);
sql = "SELECT UserName FROM UserPassword where UserName= ?";
pstmt2 = connection.prepareStatement(sql);
sql ="INSERT INTO UserPassword VALUES(?,?,?,?)";
pstmt3 = connection.prepareStatement(sql);
catch (Exception ex) {
System.err.println(ex.getMessage());
// Closes the connection and statements
// Method to be called by main class when finished with DB
public void closeConnection() {
//same as previous
public static boolean verifyEmpno(int empno) {
boolean emp_no_select_ok = false;
int emp = -1;
initConnection();
try {
pstmt1.setInt(1, empno);
ResultSet rs1 = pstmt1.executeQuery();
while(rs1.next()){
emp=rs1.getInt("empNo");
if(emp>0)
emp_no_select_ok = false;
} else{
emp_no_select_ok = true;
rs1.close();
pstmt1.close();
catch (Exception ex) {
System.err.println(ex.getMessage());
return emp_no_select_ok;
public static boolean verifyUsername(String username) {
boolean user_name_select_ok = false;
String user = "xxxx";
initConnection();
try {
pstmt2.setString(1, username);
ResultSet rs2 = pstmt2.executeQuery();
while(rs2.next()){
user=rs2.getString("UserName");
if(!user.equals("xxxx"))
user_name_select_ok = false;
} else{
user_name_select_ok = true;
rs2.close();
catch (Exception ex) {
System.err.println(ex.getMessage());
return user_name_select_ok;
public static boolean createAcc(int empno, String username, String password, int
level){
boolean create_acc_ok = false;
initConnection();
try{
//create a new object,from the UserPassword table.
UserPassword useraccount = new UserPassword();
useraccount.setEmpno(empno);
useraccount.setUsername(username);
useraccount.setPassword(password);
useraccount.setLevel(level);
//assign value for ???
pstmt3.setInt(1, useraccount.getEmpno());
pstmt3.setString(2, useraccount.getUsername());
pstmt3.setString(3, useraccount.getPassword());
pstmt3.setInt(4, useraccount.getLevel());
if(pstmt3.executeUpdate()==1) create_acc_ok=true;
pstmt3.close();
//con.close();
catch(SQLException e2){
System.err.println(e2.getMessage());
return create_acc_ok;
}here is the bean (part of it)
package data; //is it right?
import java.io.*;
import java.sql.*;
import java.util.*;
import javax.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class UserPassword
private int empno;
private String username;
private String password;
private int level;
// Constructor
public UserPassword()
this.empno = empno;
this.username = username;
this.password = password;
this.level = level;
// setters and getters are here.
// public boolean verifyEmpno() {
// return UserAccManager.verifyEmpno(empno);
// public boolean verifyUsername(String username) {
// return UserAccManager.verifyUsername(username);
// These 2 methods not compile with or without para's.So I leave that job for the
//controll class UserAccManager.java.
Now my problem is this: When I submit data, there is an error;org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: -1 in the jsp file: null
Generated servlet error:
[javac] Compiling 1 source file
C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\HRM\CreateAcc_jsp.java:8:
cannot access core.data.UserPassword
bad class file: C:\Program Files\Apache Group\Tomcat
4.1\webapps\HRM\WEB-INF\classes\core\data\UserPassword.class
class file contains wrong class: data.UserPassword
Please remove or make sure it appears in the correct subdirectory of the classpath.
import core.data.UserPassword;
^
1 error
Are there any mistakes? If so tell me where is it and how to change them.Please help.I try it that way, but it don't compile.
Error:core\data\UserPassword.java:package javax.servlet does not exist
import javax.servlet.*;
core\data\UserPassword.java:package javax.servlet.http does not exist
import javax.servlet.http.*;
So,I comment them only in the UserPassword.java file,and compile it again.
Then it compile well.I goto the directory to get the .class files.
But there is only UserPassword.class inside the data folder. There is not
UserAccManager.class in the core folder.
Then I try this way,I put my 2 java files in to a new folder,
F:\SystemName\com
When I try it that way, but it don't compile.
javac -classpath . -d . com\*.javaError:com\UserPassword.java:package javax.servlet does not exist
import javax.servlet.*;
com\UserPassword.java:package javax.servlet.http does not exist
import javax.servlet.http.*;
So,I comment them only in the UserPassword.java file,and compile it again.
Now both are compiling well.There was 2 class files.
I put them in to the WEB-INF/classes/com directory.
Start the server.But it gave errors:
C:\Program Files\Apache Group\Tomcat
4.1\work\Standalone\localhost\HRM\CreateAcc_jsp.java:68: cannot resolve symbol
symbol : variable empno
location: class org.apache.jsp.CreateAcc_jsp
if(UserPassword.verifyEmpno(empno)){
^
C:\Program Files\Apache Group\Tomcat
4.1\work\Standalone\localhost\HRM\CreateAcc_jsp.java:69: cannot resolve symbol
symbol : variable username
location: class org.apache.jsp.CreateAcc_jsp
if(UserAccManager.verifyUsername(username)){
^
C:\Program Files\Apache Group\Tomcat
4.1\work\Standalone\localhost\HRM\CreateAcc_jsp.java:69: non-static method
verifyUsername(java.lang.String) cannot be referenced from a static context
if(UserAccManager.verifyUsername(username)){
^
C:\Program Files\Apache Group\Tomcat
4.1\work\Standalone\localhost\HRM\CreateAcc_jsp.java:70: cannot resolve symbol
symbol : variable empno
location: class org.apache.jsp.CreateAcc_jsp
if(UserAccManager.createAcc(empno, username,password,level)) nextPage
="MsgAcc.jsp";
^
C:\Program Files\Apache Group\Tomcat
4.1\work\Standalone\localhost\HRM\CreateAcc_jsp.java:70: cannot resolve symbol
symbol : variable username
location: class org.apache.jsp.CreateAcc_jsp
if(UserAccManager.createAcc(empno, username,password,level)) nextPage
="MsgAcc.jsp";
^
C:\Program Files\Apache Group\Tomcat
4.1\work\Standalone\localhost\HRM\CreateAcc_jsp.java:70: cannot resolve symbol
symbol : variable password
location: class org.apache.jsp.CreateAcc_jsp
if(UserAccManager.createAcc(empno, username,password,level)) nextPage
="MsgAcc.jsp";
^
C:\Program Files\Apache Group\Tomcat
4.1\work\Standalone\localhost\HRM\CreateAcc_jsp.java:70: cannot resolve symbol
symbol : variable level
location: class org.apache.jsp.CreateAcc_jsp
if(UserAccManager.createAcc(empno, username,password,level)) nextPage
="MsgAcc.jsp";
^
C:\Program Files\Apache Group\Tomcat
4.1\work\Standalone\localhost\HRM\CreateAcc_jsp.java:70: non-static method
createAcc(int,java.lang.String,java.lang.String,int) cannot be referenced from a static
context
if(UserAccManager.createAcc(empno, username,password,level)) nextPage
="MsgAcc.jsp";
^
8 errorsTo solve the problem non-static method,I goto the UserAccManager.java file and do these
things.
package com;
import java.io.*;
import java.sql.*;
import java.util.*;
import javax.sql.*;
//import javax.servlet.*; //otherwise it tells an error.(package
//javax.servlet does not exist)
//import javax.servlet.http.*;
public class UserAccManager {
private static final String DRIVER = "com.mysql.jdbc.Driver";
private static final String URL = "jdbc:mysql://localhost:3306/superfine";
private static Connection connection;
private static PreparedStatement pstmt1;
private static PreparedStatement pstmt2;
private static PreparedStatement pstmt3;
private UserAccManager() {
// Initializes the connection and statements
private static void initConnection() {
//same
// Closes the connection and statements
// Method to be called by main class when finished with DB
public static void closeConnection() {
//same
public static boolean verifyEmpno(int empno) {
// same.
public static boolean verifyUsername(String username) {
//same.
public static boolean createAcc(int empno, String username, String password, int
level){
//same
package com;
import java.io.*;
import java.sql.*;
import java.util.*;
import javax.sql.*;
//import javax.servlet.*;
//import javax.servlet.http.*;
public class UserPassword {
// same
Again compile those files and put .class filses into the WEB-INF/classes/com directory.
When i submits the data via the form it generates an error:
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 9 in the jsp file: /CreateAcc.jsp
Generated servlet error:
[javac] Compiling 1 source file
C:\Program Files\Apache Group\Tomcat
4.1\work\Standalone\localhost\HRM\CreateAcc_jsp.java:68: cannot resolve symbol
symbol : variable empno
location: class org.apache.jsp.CreateAcc_jsp
if(UserAccManager.verifyEmpno(empno)){
^
An error occurred at line: 9 in the jsp file: /CreateAcc.jsp
Generated servlet error:
C:\Program Files\Apache Group\Tomcat
4.1\work\Standalone\localhost\HRM\CreateAcc_jsp.java:69: cannot resolve symbol
symbol : variable username
location: class org.apache.jsp.CreateAcc_jsp
if(UserAccManager.verifyUsername(username)){
^
An error occurred at line: 9 in the jsp file: /CreateAcc.jsp
Generated servlet error:
C:\Program Files\Apache Group\Tomcat
4.1\work\Standalone\localhost\HRM\CreateAcc_jsp.java:70: cannot resolve symbol
symbol : variable empno
location: class org.apache.jsp.CreateAcc_jsp
if(UserAccManager.createAcc(empno, username,password,level)) nextPage
="MsgAcc.jsp";
^
An error occurred at line: 9 in the jsp file: /CreateAcc.jsp
Generated servlet error:
C:\Program Files\Apache Group\Tomcat
4.1\work\Standalone\localhost\HRM\CreateAcc_jsp.java:70: cannot resolve symbol
symbol : variable username
location: class org.apache.jsp.CreateAcc_jsp
if(UserAccManager.createAcc(empno, username,password,level)) nextPage
="MsgAcc.jsp";
^
An error occurred at line: 9 in the jsp file: /CreateAcc.jsp
Generated servlet error:
C:\Program Files\Apache Group\Tomcat
4.1\work\Standalone\localhost\HRM\CreateAcc_jsp.java:70: cannot resolve symbol
symbol : variable password
location: class org.apache.jsp.CreateAcc_jsp
if(UserAccManager.createAcc(empno, username,password,level)) nextPage
="MsgAcc.jsp";
^
An error occurred at line: 9 in the jsp file: /CreateAcc.jsp
Generated servlet error:
C:\Program Files\Apache Group\Tomcat
4.1\work\Standalone\localhost\HRM\CreateAcc_jsp.java:70: cannot resolve symbol
symbol : variable level
location: class org.apache.jsp.CreateAcc_jsp
if(UserAccManager.createAcc(empno, username,password,level)) nextPage
="MsgAcc.jsp";
^
6 errorshere is the CreateAcc.jsp file
<%@ page language="java" %>
<%@ page import="com.UserAccManager" %>
<%@ page import="com.UserPassword" %>
<jsp:useBean id="userPassword" class="com.UserPassword" scope="request"/>
<jsp:setProperty name="userPassword" property="*" />
<%
String nextPage ="MainForm.jsp";
if(UserAccManager.verifyEmpno(empno)){
if(UserAccManager.verifyUsername(username)){
if(UserAccManager.createAcc(empno, username,password,level)) nextPage
="MsgAcc.jsp";
}else{
nextPage="UserNameExist.jsp";
else{
nextPage="UserAccError.jsp";
%>
<jsp:forward page="<%=nextPage%>"/>Please, anyone know how to send these parameters to the java file.
Thanks. -
Importing class to JSP in websphere (newbie)
Hi I am trying to figure out how to properly import a class in a JSP.
The DocumentRoot directory is set in Websphere and that is where my JSP's reside. I have created a folder off of the DocumentRoot directory called classes and placed my .class file in there. I then set the classes directory in the classpath (and restarted the appserver)
I have an import statement in my jsp for the class.
I am now getting an error that says it is unable to compile because of null. Any ideas????
Below is a test piece of JSP code and the class code:
<%@ page import="java.io.*, java.util.*, java.text.*, IPRStat, java.net.*,java.sql.*"%>
<HTML>
<BODY>
<%
try {
String IPRNum = "001-0001";
String IPRStatus = "OK";
IPRStat Testing = new IPRStat(IPRNum, IPRStatus);
} catch (Exception e) {
out.println("Error detected " + e.getMessage());
%>
</BODY>
</HTML>
class IPRStat
public IPRStat(String i, String d )
iprnum = i;
status = d;
public String getIPRNum()
return iprnum;
public String getStatus()
return status;
private String iprnum;
private String status;
-----------------------------------------------------DocumentRoot (looks something like: /aibm/Userdata/WebAsAdv/default/mydev) is where my JSP's live (i.e.)
/aibm/Userdata/WebAsAdv/default/mydev/testidea.jsp
and I made a directory off of DocumentRoot called classes:
/aibm/Userdata/WebAsAdv/default/mydev/classes
And copied IPRStat.class into the classes directory.
/aibm/Userdata/WebAsAdv/default/mydev/classes/IPRStat.class
I then put the path (/aibm/Userdata/WebAsAdv/default/mydev/classes) in the classpath and restarted the appserver.
At this point there is no Web-INF that I can see. I am new to Websphere myself. Is version 3.5.4 standard edition. I am using the websphere admin console to set the classpath. -
Importing Custom Classes into a JSP page
Hello,
I have created custom package com.srjgroup.report. It sits in C:\workspace\src\com\srjgroup\report directory. I have java files as well as compiled classes there. No jar files there.
did amend classpath to point to this directory.
In my JSP page I have the import statement as following
import="java.sql.*, java.util.*, java.text.SimpleDateFormat, com.srjgroup.report.*"It imports all the packages without any errors. However, when I try to use one of the classes in the package, I get error
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 3 in the jsp file: /SQLServer.jsp
Generated servlet error:
SRJReports cannot be resolved to a type
SRJReports is one of the classes that I am trying to use in that package. When I comment out all references to the class, everything is fine.
So, to fix this I moved the entire package to
C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\ROOT\WEB-INF\lib direcory, preserving the hierarhy. So, now my custom package is located here:
C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\ROOT\WEB-INF\lib\com\srjgroup\report again there are no jar files, only java and classes here. Still, no go.
What am I doing wrong ?Put the class in
C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\ROOT\WEB-INF\classes\com\srjgroup\report
One more thing, there is no subdirectory in lib directory. You may look at the example within tomcat for reference. I start from there. -
Hi,
I am trying to import a class into my JSP and am getting the following error at runtime:
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: -1 in the jsp file: null
Generated servlet error:
[javac] Compiling 1 source file
[javac] D:\jwsdp-1.2\work\Catalina\localhost\pe\org\apache\jsp\guestbook_jsp.java:7: '.' expected
[javac] import MessageGetter;
My import statement in the JSP is simply:
<%@ page import="MessageGetter" %>
and I am placing the class in the WEB-INF/classes directory. This is stumping me - if you've come across this or a similar problem, please let me know. Thanks.
PTry posting your question in the JSP forum (http://forum.java.sun.com/forum.jsp?forum=45)
cheers,
Mike
Maybe you are looking for
-
Problems began when Firefox 13 automatically updated. tried downloading latest version of Flash 11.2.202.235. No change. Video works sometimes on YouTube, not at all on most other sites. Audio player not working at all. Either not even visible or dow
-
Records print on next page in samrtforms
Hi all gurus and experts of sap .... I had created P.O layout in smartforms .....when number of line items increased that time it breaks the page and footer area print on next page .... kindly suggest me how to print remaining lines on next subsquen
-
Set Minimum amount for non LVA Asset Class
Dear all, Is it possible to set a minimum amount for asset classes other LVA asset class? Thanks & regards.
-
I don't think this should be happening, but I haven't been able to find any reference to such a situation in Apple Support or on Forums.
-
Wont turn on just flashes apple sign, for an ipad 2 what would cause this to happen When I tried to restore started to flash the dead battery sign