One option.
If you are not sure about the parameters coming into the servlet/jsp, the
only way is to catch the NullPointer exception.
Group the parameters into different categories.
1. params which are passed all the time. This has got no problem
2. Different groups for params coming from different sources. All these
groups can be treated together in one try-catch block.
The script will be
// Declare all the variable at the top.
String common1,common2,group1something ............(etc).
// Common Parameters.
common1=getParameter("common1");
common2=getParameter("common2");
// Parameters of Group1
try{
group1someting=getParameter("group1tag1");
group1somethingelse=getParameter("group1tag2");
}catch (Exception NullPointerException npe)
{
// Put some default values for the variables, if required.
}
// Parameters of Group2
try{
group2someting=getParameter("group2tag1");
group2somethingelse=getParameter("group2tag2");
}catch (Exception NullPointerException npe)
{
// Put some default values for the variables, if required.
}
Regards,
Dantus
----- Original Message -----
From: Venkata Ratnam Vadlamannati <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, February 23, 2001 7:00 PM
> Hi All
>
> When we more than one querystring in JSP, how do we
> read then in the next page, because if we use
> request.getQueryString(), it returns the whole string
> after '?'
>
> and if we use request.getParameter("parameterName"),
> it works fine, but when requests come from different
> pages and they do not contain this parameter, it
> throws nullpointer exception.
>
> In detail:
>
> abc.jsp?id=123, in abc.jsp we can read id by using
> request.getParameter("id"), but if a request comes
> from another page, say, xyz.jsp to abc.jsp without any
> parameter, abc.jsp throws expection
>
> Is there any better way of dealing with these
> querystrings/parameters. any examples/links are
> highly appreciated
>
> Regards
>
> Mahesh
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Auctions - Buy the things you want at great prices!
http://auctions.yahoo.com/
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets