Re: How pass a form parameter value to a same jsp file?
From: jajoo (jivkoto_at_abv.bg)
Date: 01/23/04
- Next message: Theo: "Re: Mars Rover Not Responding"
- Previous message: hiwa: "Re: Problem Solved!"
- In reply to: kaiwing18_at_hotmail.com: "How pass a form parameter value to a same jsp file?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 23 Jan 2004 02:44:42 -0800
Hi Ricky,
I think that you doing it right except that: When you first load the
jsp, this code request.getParameter("sort"); whill return null because
at the first load you do not have sort parameter. So sort1=null.
Because sort1=null sort1.equals("Asset_Number") will return
NullPointerException.
You should do this:
1)First way - to check if sort1==null
<% String sort1=request.getParameter("sort");
String i=" ";
if(sort1!=null){ // you should check if sort == null
if (sort1.equals("Asset_Number"))
i="Asset_Number";
else if(sort1.equals("Description"))
i="Description";
else
i="Type";
}else{
i="Type";
}
%>
2)Second way use "Some string".equals(sort1)- if sort1==null no
Exception trown
<% String sort1=request.getParameter("sort");
String i=" ";
if ("Asset_Number".equals(sort1)) i="Asset_Number";
else if("Description".equals(sort1)) i="Description";
else
i="Type";
%>
I think that both ways solve your problem.
Zhivko Mitrev
- Next message: Theo: "Re: Mars Rover Not Responding"
- Previous message: hiwa: "Re: Problem Solved!"
- In reply to: kaiwing18_at_hotmail.com: "How pass a form parameter value to a same jsp file?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]