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
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