How should I model parameter passing in JSP and the relationship between JSP and JavaBeans using UML?

jim conallen

Parameters

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

    
    +------------------+                              +--------------------+
    | <<client page>>  |         <<link>>        0..n |  <<server page>>   |  
    |     Catalog      |----------------------------->|    Product.jsp     |
    +------------------+         {prameters="prodid"} +--------------------+
                                                              |
                                                    <<build>> |
                                                              |
                                                              |
                                                              V
                                                    +--------------------+
                                                    |  <<client page>>   |
                                                    |     Product.html   |
                                                    +--------------------+

In the above example the link from Catalog to Product.jsp indicates that a standard anchor tag is used (i.e. <a>) 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 <<link>> 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.

    
    +------------------+                              +--------------------+
    | <<client page>>  |          <<link>>            |  <<server page>>   |  
    |     HomeMonitor  |----------------------------->|    HomeControl.jsp |
    +------------------+                             +--------------------+
                                 
                                  
                           +-------------------+
                           |  <<parameters>>   |
                           |    ControlInfo    |
                           +-------------------+
                           | homeid : long     |
                           | deviceid : long   |
                           | action : enum     |
                           | value : string    |
                           +-------------------+

Beans

Modeling bean usage in a JSP begins with a <<use bean>> stereotyped directional association from a <<server page>> class to the bean.
    
    +------------------+                                         +--------------------+
    | <<server page>>  |       <<use 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.

<jsp:usebean id="mySched" class="com.mycompany.myproj.mysubsys.DutyScheduleBean" type="com.mycompany.myproj.comiface.Schedule" scope="session">
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact