Win a copy of Mastering Corda: Blockchain for Java Developers this week in the Cloud/Virtualization forum!
    Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

jsp:useBean

 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Hi,

This isn't the right forum for my question, but I was sure, you guys would be able to answer my question for sure. Please excuse.

Heres my doubt.

I have an html addressForm.html calling address.jsp, on submitting the form.
In address.jsp, I use the bean AddressBean to capture the form variables into an object of type AddressBean.

Path of the files relative to document root:
addressForm.html: /
address.jsp: /
AddressBean.class: /WEB-INF/classes

I get "unable to complile jsp file" error.

symbol : class AddressBean
location: class org.apache.jsp.address_jsp
AddressBean address = null;
^


Heres the code:

addressForm.html
--------------------
<html>
<body>
Please give your address: <br>
<form action = "address.jsp" >
<pre>
Street: <input type="text" name="street"><br>
City: <input type="text" name="city"><br>
State: <input type="text" name="state"><br>
Zip: <input type="text" name="zip"><br>
<input type="submit">
</pre>
</form>
</body>
</html>

adress.jsp
-----------
<%@ page import="AddressBean" %>
<jsp:useBean id="address" class="AddressBean" scope="session"/>
<jsp:setProperty name="address" property="*" />

<HTML>
<BODY>
HI</BODY>
</HTML>

AddressBean.java
---------------

public class AddressBean
{

private String street;
private String city;
private String state;
private String zip;



public void setStreet(String street){ this.street = street; }
public void setCity(String city){ this.city = city; }
public void setState(String state){ this.state = state; }
public void setZip(String zip){ this.zip = zip; }


public String getStreet(){ return this.street; }
public String getCity(){ return this.city; }
public String getState(){ return this.state; }
public String getZip(){ return this.zip; }


}
 
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
This is common issue in some of the servers. Try putting your bean in a package and modify the useBean tag as in:

package mypack;

public class AddressBean {
. . .
}

and in your JSP:

<%@ page import="mypack.AddressBean" %>
<jsp:useBean id="address" class="AddressBean" scope="session"/>
<jsp:setProperty name="address" property="*" />

You WEB-INF/classes folder should then look like:


This should work for you.
 
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I'm closing this thread, because its a duplicate of this one. So please post your replies there. Thanks!
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic