wood burning stoves 2.0*
The moose likes Servlets and the fly likes JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "JSP" Watch "JSP" New topic
Author

JSP

krupa devi
Greenhorn

Joined: Jul 02, 2001
Posts: 14
Hi,
I think this is a very basic question.
I am getting an error when I am loading RetrieveFormData.jsp
here is my code.
CreateForm.jsp
<html>
<head>
<title>CREATING A JSP FORM</title>
</head>

</body>
<form Action = "RetrieveFormData.jsp" Method = "Post">
<table align = "center" cellspacing = "2" cellpadding = "2" border = "1">
<tr>
<td colspan ="3">

<b>Company:</b>
<%
String company = request.getParameter("company");
if ( company != null)
{

%>
<input type = "text"
name = "company"
value = " <%= company %>"
size = "40"
maxlength = "40">

<%
}
else
{
%>
<input type = "text"
name = "company"
size = "40"
maxlength = "40">

<%
}
%>
</td>
</tr>
<tr>
<td colspan = "3">
<b>Street:</b>
<input type = "text"
name = "Street"
size = "40"
maxlength = "40">
</td>
</tr>
<tr>
<td colspan = "3">
<b>State:</b>
<input type = "text"
name = "State"
size = "40"
maxlength = "40">
</td>
</tr>
<tr>
<td colspan = "3">
<b>City:</b>
<input type = "text"
name = "City"
size = "40"
maxlength = "40">
</td>
</tr>

<tr>
<td>
<input type ="submit" value = "Submit">
</td>
</tr>
</table>
</Form>
</body>
</html>
RetrieveFormData.jsp
<jsp:usebean id ="company" scope = "request" class = "shoppingcart.Company"/>
jsp:setProperty name = "company" property = "*" />
<html>
<head>
<title> Retrieve form data </title>
</head>
<body>
<B> Company: </b> <%= company.getCompany()%> <br>
<B> Street : </b> <%= company.getStreet() %> <br>
<B> State : </b> <%= company.getState() %> <br>
<B> City : </b> <%= company.getCity() %> <br>
<B> Zip : </b> <%= company.getZip() %> <br>
</body>
</html>

Company.java
package shoppingcart;
public class Company
{
private String company = null;
private String street = null;
private String city = null;
private String state = null;
private String zip = null;

public Company()
{
}
// setters and getters for Company
public String getCompany()
{
return company;
}
public void setCompany(String value)
{
company = value;
}
// setters and getters for street
public String getStreet()
{
return street ;
}
public void setStreet(String value)
{
street = value;
}
// setters and getters for state
public String getState()
{
return state;
}
public void setState(String value)
{
state = value;
}
// setters and getters for city
public String getCity()
{
return city;
}
public void setCity(String value)
{
city = value;
}
// setters and getters for Zip
public String getZip()
{
return zip;
}
public void setZip(String value)
{
zip = value;
}
}

on clicking the submit button I am getting the following error
Location: /examples/jsp/RetrieveFormData.jsp
Internal Servlet Error:
org.apache.jasper.JasperException: Unable to compile class for JSPD:\jakarta-tomcat\work\localhost_8080%2Fexamples\_0002fjsp_0002fRetrieveFormData_0002ejspRetrieveFormData_jsp_1.java:61: Undefined variable or class name: company
out.print( company.getCompany());
I have shoppingcart folder in D:/jakarta_tomcat/webapps/WEB_INF/
I have company.java and company.class are in this shopping cart folder.
I have createform.jsp and retrieveFormData.jsp are in the
D:/jakarta_tomcat/webapps/examples/JSP
Please bare with my ignorance. I am having a hard time with directory structure. I really thank Javaranch for helping so many people like me.
Thanks to all,
Krupa
Roopa Bagur
Ranch Hand

Joined: Nov 03, 2000
Posts: 267
Hi Krupa,
It looks like it is syntax problem since it is failing at compile. You need a left angled bracket in the following line of your code..Add that & compile again.
jsp:setProperty name = "company" property = "*" />

Originally posted by krupa devi:
Hi,
I think this is a very basic question.
I am getting an error when I am loading RetrieveFormData.jsp
here is my code.
CreateForm.jsp
<html>
<head>
<title>CREATING A JSP FORM</title>
</head>

</body>
<form Action = "RetrieveFormData.jsp" Method = "Post">
<table align = "center" cellspacing = "2" cellpadding = "2" border = "1">
<tr>
<td colspan ="3">

<b>Company:</b>
<%
String company = request.getParameter("company");
if ( company != null)
{

%>
<input type = "text"
name = "company"
value = " <%= company %>"
size = "40"
maxlength = "40">

<%
}
else
{
%>
<input type = "text"
name = "company"
size = "40"
maxlength = "40">

<%
}
%>
</td>
</tr>
<tr>
<td colspan = "3">
<b>Street:</b>
<input type = "text"
name = "Street"
size = "40"
maxlength = "40">
</td>
</tr>
<tr>
<td colspan = "3">
<b>State:</b>
<input type = "text"
name = "State"
size = "40"
maxlength = "40">
</td>
</tr>
<tr>
<td colspan = "3">
<b>City:</b>
<input type = "text"
name = "City"
size = "40"
maxlength = "40">
</td>
</tr>

<tr>
<td>
<input type ="submit" value = "Submit">
</td>
</tr>
</table>
</Form>
</body>
</html>
RetrieveFormData.jsp
<jsp:usebean id ="company" scope = "request" class = "shoppingcart.Company"/>
jsp:setProperty name = "company" property = "*" />
<html>
<head>
<title> Retrieve form data </title>
</head>
<body>
<B> Company: </b> <%= company.getCompany()%> <br>
<B> Street : </b> <%= company.getStreet() %> <br>
<B> State : </b> <%= company.getState() %> <br>
<B> City : </b> <%= company.getCity() %> <br>
<B> Zip : </b> <%= company.getZip() %> <br>
</body>
</html>

Company.java
package shoppingcart;
public class Company
{
private String company = null;
private String street = null;
private String city = null;
private String state = null;
private String zip = null;

public Company()
{
}
// setters and getters for Company
public String getCompany()
{
return company;
}
public void setCompany(String value)
{
company = value;
}
// setters and getters for street
public String getStreet()
{
return street ;
}
public void setStreet(String value)
{
street = value;
}
// setters and getters for state
public String getState()
{
return state;
}
public void setState(String value)
{
state = value;
}
// setters and getters for city
public String getCity()
{
return city;
}
public void setCity(String value)
{
city = value;
}
// setters and getters for Zip
public String getZip()
{
return zip;
}
public void setZip(String value)
{
zip = value;
}
}

on clicking the submit button I am getting the following error
Location: /examples/jsp/RetrieveFormData.jsp
Internal Servlet Error:
org.apache.jasper.JasperException: Unable to compile class for JSPD:\jakarta-tomcat\work\localhost_8080%2Fexamples\_0002fjsp_0002fRetrieveFormData_0002ejspRetrieveFormData_jsp_1.java:61: Undefined variable or class name: company
out.print( company.getCompany());
I have shoppingcart folder in D:/jakarta_tomcat/webapps/WEB_INF/
I have company.java and company.class are in this shopping cart folder.
I have createform.jsp and retrieveFormData.jsp are in the
D:/jakarta_tomcat/webapps/examples/JSP
Please bare with my ignorance. I am having a hard time with directory structure. I really thank Javaranch for helping so many people like me.
Thanks to all,
Krupa

krupa devi
Greenhorn

Joined: Jul 02, 2001
Posts: 14
Sorry , it is working now.
 
jQuery in Action, 2nd edition
 
subject: JSP
 
Similar Threads
hide email and password on contactus jsp
Jasper compile error
I am unable to find error in this program.
getting error while excuting the jsp page
Cache Problem in Jsp...