Problem on java bean

V

Vincent Ho

I'm a newbie in JSP and test a sample code from a online tutorial.
However I got error on this (I'm using Apache + Tomcat + Linux):

description
The server encountered an internal error () that prevented it from
fulfilling this request.

exception
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 0 in the jsp file: /test/SaveName.jsp

Generated servlet error:
[javac] Since fork is true, ignoring compiler setting.
[javac] Compiling 1 source file
[javac] Since fork is true, ignoring compiler setting.
[javac] /usr/local/tomcat/work/Standalone/localhost/_/test/SaveName_jsp.java:41:
cannot resolve symbol
[javac] symbol : class UserData
[javac] location: class org.apache.jsp.SaveName_jsp
[javac] UserData user = null;
[javac] ^
.........................

My code is as follow:
-- GetName.jsp --
<HTML>
<BODY>
<FORM METHOD=POST ACTION="SaveName.jsp">
What's your name? <INPUT TYPE=TEXT NAME=username SIZE=20><BR>
What's your e-mail address? <INPUT TYPE=TEXT NAME=email SIZE=20><BR>
What's your age? <INPUT TYPE=TEXT NAME=age SIZE=4>
<P><INPUT TYPE=SUBMIT>
</FORM>
</BODY>
</HTML>


-- SaveName.jsp --
<jsp:useBean id="user" class="UserData" scope="session"/>
<jsp:setProperty name="user" property="*"/>
<HTML>
<BODY>
<A HREF="NextPage.jsp">Continue</A>
</BODY>
</HTML>

-- UserData.java --
public class UserData {
String username;
String email;
int age;
public void setUsername( String value )
{
username = value;
}
public void setEmail( String value )
{
email = value;
}
public void setAge( int value )
{
age = value;
}
public String getUsername() { return username; }
public String getEmail() { return email; }
public int getAge() { return age; }
}

Here is my environment variable configuration:
JAVA_HOME=/usr/java/j2sdk1.4.2
CLASSPATH=/usr/local/tomcat/webapps/ROOT/WEB-INF

I placed my jsp files in /usr/local/tomcat/webapps/ROOT/test.

I think it may because I put the class files into a wrong place.
I try to put the java and compiled class in
/usr/local/tomcat/webapps/ROOT/WEB-INF/classes. However it failed.

Can anyone tell me where I should put the files and any problem I
made? Thanks a lot.

Vincent
 
J

John C. Bollinger

Vincent said:
I'm a newbie in JSP and test a sample code from a online tutorial.
However I got error on this (I'm using Apache + Tomcat + Linux):

description
The server encountered an internal error () that prevented it from
fulfilling this request.

exception
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 0 in the jsp file: /test/SaveName.jsp

Generated servlet error:
[javac] Since fork is true, ignoring compiler setting.
[javac] Compiling 1 source file
[javac] Since fork is true, ignoring compiler setting.
[javac] /usr/local/tomcat/work/Standalone/localhost/_/test/SaveName_jsp.java:41:
cannot resolve symbol
[javac] symbol : class UserData
[javac] location: class org.apache.jsp.SaveName_jsp
[javac] UserData user = null;
[javac] ^
........................
[...]

-- SaveName.jsp --
<jsp:useBean id="user" class="UserData" scope="session"/>
<jsp:setProperty name="user" property="*"/>
<HTML>
<BODY>
<A HREF="NextPage.jsp">Continue</A>
</BODY>
</HTML>

-- UserData.java --
public class UserData {
String username;
[...]

I placed my jsp files in /usr/local/tomcat/webapps/ROOT/test.

I think it may because I put the class files into a wrong place.
I try to put the java and compiled class in
/usr/local/tomcat/webapps/ROOT/WEB-INF/classes. However it failed.

Can anyone tell me where I should put the files and any problem I
made? Thanks a lot.

You need to assign your bean class to a package, and to specify that
package in your useBean action. You cannot use the default package for
this sort of thing.


John Bollinger
(e-mail address removed)
 
V

Vincent Ho

how to do it? can u give me example?

John C. Bollinger said:
Vincent said:
I'm a newbie in JSP and test a sample code from a online tutorial.
However I got error on this (I'm using Apache + Tomcat + Linux):

description
The server encountered an internal error () that prevented it from
fulfilling this request.

exception
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 0 in the jsp file: /test/SaveName.jsp

Generated servlet error:
[javac] Since fork is true, ignoring compiler setting.
[javac] Compiling 1 source file
[javac] Since fork is true, ignoring compiler setting.
[javac] /usr/local/tomcat/work/Standalone/localhost/_/test/SaveName_jsp.java:41:
cannot resolve symbol
[javac] symbol : class UserData
[javac] location: class org.apache.jsp.SaveName_jsp
[javac] UserData user = null;
[javac] ^
........................
[...]

-- SaveName.jsp --
<jsp:useBean id="user" class="UserData" scope="session"/>
<jsp:setProperty name="user" property="*"/>
<HTML>
<BODY>
<A HREF="NextPage.jsp">Continue</A>
</BODY>
</HTML>

-- UserData.java --
public class UserData {
String username;
[...]

I placed my jsp files in /usr/local/tomcat/webapps/ROOT/test.

I think it may because I put the class files into a wrong place.
I try to put the java and compiled class in
/usr/local/tomcat/webapps/ROOT/WEB-INF/classes. However it failed.

Can anyone tell me where I should put the files and any problem I
made? Thanks a lot.

You need to assign your bean class to a package, and to specify that
package in your useBean action. You cannot use the default package for
this sort of thing.


John Bollinger
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top