How to model parameter passing in JSP?
1 posts in topic
Flat View  Flat View

Posted By:   Shirley_Leung
Posted On:   Sunday, May 13, 2001 11:18 PM

With Web Application Extension, how should I model parameter passing in JSP?
How to model the relationship between JSP and Java Bean?

Re: How to model parameter passing in JSP?

Posted By:   jim_conallen  
Posted On:   Monday, May 14, 2001 08:39 AM


There are two principal ways to model parameters
being passed from a HTML source on the client to a <>
on the server. The first is to put them in a tag value, called parameters. For

+------------------+ +--------------------+
| <> | <> 0..n | <> |
| Catalog |----------------------------->| Product.jsp |
+------------------+ {prameters="prodid"} +--------------------+
<> |
| <> |
| Product.html |

In the above example the link from Catalog to Product.jsp indicates that a standard
anchor tag is used (i.e. ) and that appended to the url is the parameter
prodid. At design time this parameter is not given any value, since it is likely to
be runtime generated thing. Also note that in this catalog page there are potentially
many links to product pages, all with potentially different prodid params.

Multiple parameters can be passed simply be adding them in the string just as you
would append them to the url. For example if the parameters tag value was
"action=add&prodid&qty". It would indicate that at design time the parameter action
was always set to add, and the values for prodid and qty are either not specified, or are
specified at runtime.

If the parameters being passed to the server are more complex, and where it might be useful
to document heavily each and every one. Then you might want to model them as and association
class on the <> association. This lets you not only specific all the parameters,
but gives you an oppertuity to specify datatypes, and default values for each. This of course is
overkill for most simple parameter usages, but is handy for those special occasions.

+------------------+ +--------------------+
| <> | <> | <> |
| HomeMonitor |----------------------------->| HomeControl.jsp |
+------------------+ +--------------------+

| <> |
| ControlInfo |
| homeid : long |
| deviceid : long |
| action : enum |
| value : string |


Modeling bean usage in a JSP begins with a <> stereotyped directional
association from a <> class to the bean.
+------------------+ +--------------------+
| <> | <> mySched : Schedule | |
| Calendar.jsp |---------------------------------------->| DutyScheduleBean |
+------------------+ {scope=session} +--------------------+

The role name corresponds to the jsp:usebean id attribute, the role specifier Schedule corresponds
to the type attribute, and the tag value for scope is the use bean scope attribute. The
beanname attribute is another valid tag value that can be specified at design time.

About | Sitemap | Contact