aspose file tools*
The moose likes Servlets and the fly likes using request parameters to set up a bean via servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "using request parameters to set up a bean via servlet" Watch "using request parameters to set up a bean via servlet" New topic
Author

using request parameters to set up a bean via servlet

muktesh tripathi
Ranch Hand

Joined: Nov 20, 2007
Posts: 30
Well there is a
<jsp:useBean id="retire" scope="application" class="com.MyBean" />
<jsp:setProperty name="retire" property="*" />


This sets up all the bean properties which have matching names in submitted form automatically.

My question is that is there any such great method in servlets to set up a bean using request parameters automatically???
I want to send form parameters to a servlet that should set up the bean as attribute to be used by full application...
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61648
    
  67

Not per se. But it's pretty easy to do it using the bean methods. There are also a lot of 3rd party bean-handling libraries out there that might have something similar.

P.S. Submitting to a servlet is a much better practice than submitting to a JSP, even if it does seem like more work at first.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
muktesh tripathi
Ranch Hand

Joined: Nov 20, 2007
Posts: 30
But it's pretty easy to do it using the bean methods.


Thanks , But can you please give little more detail..may be an example..Thanks again..

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61648
    
  67

Check out the classes and methods in the java.beans package, and perhaps the Commons BeanUtils library.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: using request parameters to set up a bean via servlet