View Single Post
Old 09-27-2012, 11:12 PM   PM User | #1
billatl
New Coder

 
Join Date: Oct 2009
Posts: 51
Thanks: 6
Thanked 0 Times in 0 Posts
billatl is an unknown quantity at this point
Question Testing Value of QueryString

Hello,

I'm trying to get the full URL of a webpage and am running into a problem testing the query string. Here's my code so far:

Code:
String requestURL = request.getRequestURL().toString();
String queryString = request.getQueryString();

<%= requestURL %>+<%= queryString %>

if (queryString.equals("")) {
   out.println("is null"); 
} else {
	out.println("not null");
This code works fine so long as there is a query string; if not I get a runtime error on the IF statement. I tried changing queryString definition to request.getQueryString().toString; - but it also fails if there's no queryString.

Perhaps a better question is, how do I properly test for null

Thanks
billatl is offline   Reply With Quote