aspose file tools*
The moose likes JSP and the fly likes The value for the useBean class attribute StringBean is invalid Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "The value for the useBean class attribute StringBean is invalid" Watch "The value for the useBean class attribute StringBean is invalid" New topic
Author

The value for the useBean class attribute StringBean is invalid

Rupal Rshah
Greenhorn

Joined: Aug 13, 2010
Posts: 19
Hello Friends..

I am using Tomcat 6.0.20 and trying to use beans in JSP..

The JSP file is under a folder JSPWork....and the web.xml is under the WEB-INF folder within JSPWork and the class file for bean is under classes folder of the WEB-INF of JSPWork.

the code in StringBean.jsp is:
<html>
<head>
<title>Using JavaBeans with JSP</title>
</head>

<body>
<table border="5" align="center">
<tr> <th> Using JavaBeans with JSP</th>
</table>

<jsp:useBean id="StringBean" class="StringBean" scope="session"/>


<ol>
<li>Initial Value (from jsp:getProperty):
<i><jsp:getProperty name="StringBean" property="message"/></i> </li>

<li>Initial Value (from jsp expression):
<i><%= StringBean.getMessage() %></i> </li>

<li><jsp:setProperty name="StringBean" property="message" value="I Love Beans"/>
Value after setting property with jsp:setProperty:
<i><jsp:getProperty name="StringBean" property="message"/></i>
</li>

<li><% StringBean.setMessage("I Love Web Techno"); %></i>
Value after setting property with scripplet:
<i><%= StringBean.getMessage() %></i>
</li>
</ol>
</body>
</html>


************THe StringBean.java *************

public class StringBean {
private String message = "Initialized....";

public StringBean() {}
public String getMessage() {
return(message);
}

public void setMessage(String message){
this.message = message;
}
}


******************WEB.xml***********
<servlet>
<servlet-name>StringBean</servlet-name>
<servlet-class>StringBean</servlet-class>
</servlet>


<servlet-mapping>
<servlet-name>StringBean</servlet-name>
<url-pattern>/StringBean</url-pattern>
</servlet-mapping>


Its is giving the error as class is invalid.....

Pease help


With Regards & Thanks

Rupal
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61415
    
  67

"Rupal Sh", please check your private messages for an important administrative matter. Thanks.

Also, please be sure to use code tags when posting code to the forums. Unformatted or unindented code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please click this link ⇒ UseCodeTags ⇐ for more information.

Properly indented and formatted code greatly increases the probability that your question will get quicker, better answers.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61415
    
  67

All classes used in web applications must be in a package other than the default.
Rupal Rshah
Greenhorn

Joined: Aug 13, 2010
Posts: 19
thanks for the specification...will take care next onwards...

but putting in package does not work...
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61415
    
  67

Please read ItDoesntWorkIsUseless. Please elaborate.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: The value for the useBean class attribute StringBean is invalid