This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript 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: 1436
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: 1436
Thanks. Works great!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Checking for none existing Attribute