A
Asad
I want to try out a simple JSP example that uses beans. The code is
given below (there are four files). What I don't understand is where
do I have to put these files. I guess the file I have really doubts
about is UserData.java which is the bean file. I tried putting all 4
files in C:\tomcat4\webapps\ROOT and I also tried putting the 3 files
in C:\tomcat4\webapps\webdir and UserData.java in
C:\tomcat4\webapps\webdir\WEB-INF\classes but nothing seems to work. I
keep getting this error:
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 0 in the jsp file: /SaveName.jsp
So can someone help me determine the correct directory structure and
where to put files. Thanks.
-------------------
(GetName.html)
<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>
(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; }
}
(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>
(NextPage.jsp)
<jsp:useBean id="user" class="UserData" scope="session"/>
<HTML>
<BODY>
You entered<BR>
Name: <%= user.getUsername() %><BR>
Email: <%= user.getEmail() %><BR>
Age: <%= user.getAge() %><BR>
</BODY>
</HTML>
given below (there are four files). What I don't understand is where
do I have to put these files. I guess the file I have really doubts
about is UserData.java which is the bean file. I tried putting all 4
files in C:\tomcat4\webapps\ROOT and I also tried putting the 3 files
in C:\tomcat4\webapps\webdir and UserData.java in
C:\tomcat4\webapps\webdir\WEB-INF\classes but nothing seems to work. I
keep getting this error:
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 0 in the jsp file: /SaveName.jsp
So can someone help me determine the correct directory structure and
where to put files. Thanks.
-------------------
(GetName.html)
<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>
(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; }
}
(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>
(NextPage.jsp)
<jsp:useBean id="user" class="UserData" scope="session"/>
<HTML>
<BODY>
You entered<BR>
Name: <%= user.getUsername() %><BR>
Email: <%= user.getEmail() %><BR>
Age: <%= user.getAge() %><BR>
</BODY>
</HTML>