*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes using param attribute Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "using param attribute" Watch "using param attribute" New topic
Author

using param attribute

H Singh
Ranch Hand

Joined: Apr 03, 2005
Posts: 34
Hey Guys:

I am trying to implement " Going straight from the request to the JSP without going through a servlet" - page 358 of HFSJ

Below is my code:

form.html

<html><body>
<form action="TestBean.jsp">
name: <input type="text" name="userName">
<input type="submit">
</form>
</body></html>

TestBean.jsp

<html><body>
<jsp:useBean id="person" class="com.example.Person" />
<jsp:setProperty name="person" property="name" param="userName" />
</body></html>

Person.java

package com.example;

public class Person{

private String name;

public void setName(String name){
this.name = name;
}

public String getName(){
return name;
}
}

I get the following error :

The value for the useBean class attribute com.example.Person is invalid.
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)

i do not understand the use of id="person" here. Can someone tell me how to use param attribute correctly
Anand Wadhwani
Ranch Hand

Joined: Mar 21, 2005
Posts: 151
Hi HS...

Firstly, I am wondering what's your name: HS ?

Anyway...

I tried your code on my PC on tomcat-5, it worked fine! Though useBean tag was incomplete, so I closed it properly and I used an EL expression to print the value.

Here is updated JSP with my changes in bold:



Also notice that on 2nd line in above jsp the useBean tag closing angle bracket is without slash, left open and the tag is closed on line-4

The EL expression on line-5 prints whatever was input in text box on form.html

Hope it works with you also now!
[ June 18, 2005: Message edited by: Anand Wadhwani ]

SCWCD 1.4<br />---------------------<br />Ability is what you're capable of. <br />Motivation determines what you do. <br />Attitude determines how well you do it.<br />---------------------
H Singh
Ranch Hand

Joined: Apr 03, 2005
Posts: 34
Thanks a lot Anand....it worked
 
wood burning stoves
 
subject: using param attribute
 
Similar Threads
jsp:getProperty
value for useBean class is invalid
Param Attribute doubts
Bean standard action doubt
jsp:setProperty