File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

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 action="TestBean.jsp">
name: <input type="text" name="userName">
<input type="submit">


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

package com.example;

public class Person{

private String name;

public void setName(String name){ = name;

public String getName(){
return name;

I get the following error :

The value for the useBean class attribute com.example.Person is invalid.

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 ?


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 worked
I agree. Here's the link:
subject: using param attribute
It's not a secret anymore!