This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Checking if a variable is set or not in jsp  RSS feed

 
Saurabh nitrr
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how to check a variable passed from an html page is set or not in jsp.
is there any function equvalent to isset() as in PHP
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JR.

By variable, do you mean request parameter ?
 
Saurabh nitrr
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yeah the that variable that is accessed using request.getParameter()
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am afraid this will have to suffice

boolean isSet = (request.getParameter("your_parameter_goes_here") == null);

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65830
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use the empty operator:

<c:if test="${empty param.whatever}"> ...
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use the empty operator:

<c:if test="${empty param.whatever}"> ...


boolean isSet = (request.getParameter("your_parameter_goes_here") == null);


Checking if a variable is set or not in jsp


Yikes ! I mistook the context for a servlet instead of a JSP. Thanks for posting the JSTL.

Never use java code in a JSP.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!