Setting up directory structure in JSP

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

Andrew Thompson

I want to try out a simple JSP ...

Some limited experience, take my advice as,
'(shrugs) Well try it'.
C:\tomcat4\webapps\webdir\WEB-INF\classes but nothing seems to work. I ....
(UserData.java)

package test;
public class UserData {

And put it in...
C:\tomcat4\webapps\webdir\WEB-INF\classes\test

HTH
 

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,968
Messages
2,570,153
Members
46,701
Latest member
XavierQ83

Latest Threads

Top