File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

using param attribute

 
H Singh
Ranch Hand
Posts: 34
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 151
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
H Singh
Ranch Hand
Posts: 34
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Anand....it worked
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic