aspose file tools*
The moose likes JSP and the fly likes Checking for none existing Attribute Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Checking for none existing Attribute" Watch "Checking for none existing Attribute" New topic
Author

Checking for none existing Attribute

Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1466
    
    1
Suppose I have one sevvlet that is called by two different JSP's. The first JSP has a form with two named attributes that it sends as parameters. The second JSP does not have any named attributes to send along. How can I set the servlet code to accept either.

My servlet code:

Jenn Person
Ranch Hand

Joined: Jan 16, 2005
Posts: 89
I'm certain there is a more elegant solution, but I would just test the incoming paramater to see if it's null or not.

if (request.getParameter("my_parameter") != null)
{
//do something
}
else
{
//do something else
}
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1466
    
    1
Thanks. Works great!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Checking for none existing Attribute