You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Seth Brahler <sp...@cornell.edu> on 2002/06/27 15:15:36 UTC

URL Variable Error Checking

I'm trying to make an update page as fool-proof as possible, but there is 
one error I cannot stop.

At the top of my page I placed this code to incase the user backs off the 
url variable. For example, changing the URL 
www.mysite.com/update.jsp?ID=4  to www.mysite.com/update.jsp:

<% if(request.getParameter("ID") ==null) {
%>
  Stop update
<% } else { %>
  Continue Update
<% } %>

However, if I only back off part of the URL variable and change it to 
www.mysite.com/update.jsp?ID=, then I get the error:
  Syntax error (missing operator) in query expression 'ID =

How can I stop this error? I know in cold fusion there was a Parameter 
Exists tag, but I don't know about JSP.

Thank you.



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: URL Variable Error Checking

Posted by David Cassidy <da...@twocats.co.uk>.
if a parameter gets passed as ID=
then the value you get is ""  ie a zero length string....

So....
Your
if(request.getParameter("ID") ==null)

needs to grow to ...

if(request.getParameter("ID") ==null || 
"".equals(request.getParameter("ID"))


David

Seth Brahler wrote:

> I'm trying to make an update page as fool-proof as possible, but there 
> is one error I cannot stop.
>
> At the top of my page I placed this code to incase the user backs off 
> the url variable. For example, changing the URL 
> www.mysite.com/update.jsp?ID=4  to www.mysite.com/update.jsp:
>
> <% if(request.getParameter("ID") ==null) {
> %>
>  Stop update
> <% } else { %>
>  Continue Update
> <% } %>
>
> However, if I only back off part of the URL variable and change it to 
> www.mysite.com/update.jsp?ID=, then I get the error:
>  Syntax error (missing operator) in query expression 'ID =
>
> How can I stop this error? I know in cold fusion there was a Parameter 
> Exists tag, but I don't know about JSP.
>
> Thank you.
>
>
>
> -- 
> To unsubscribe, e-mail:   
> <ma...@jakarta.apache.org>
> For additional commands, e-mail: 
> <ma...@jakarta.apache.org>
>




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: URL Variable Error Checking

Posted by Mark O'Driscoll <ma...@eircom.net>.
Try getParameterNames(). This returns a list of parameters. You can then
check if your one is there.
----- Original Message -----
From: "Seth Brahler" <sp...@cornell.edu>
To: <to...@jakarta.apache.org>
Sent: Thursday, June 27, 2002 2:15 PM
Subject: URL Variable Error Checking


> I'm trying to make an update page as fool-proof as possible, but there is
> one error I cannot stop.
>
> At the top of my page I placed this code to incase the user backs off the
> url variable. For example, changing the URL
> www.mysite.com/update.jsp?ID=4  to www.mysite.com/update.jsp:
>
> <% if(request.getParameter("ID") ==null) {
> %>
>   Stop update
> <% } else { %>
>   Continue Update
> <% } %>
>
> However, if I only back off part of the URL variable and change it to
> www.mysite.com/update.jsp?ID=, then I get the error:
>   Syntax error (missing operator) in query expression 'ID =
>
> How can I stop this error? I know in cold fusion there was a Parameter
> Exists tag, but I don't know about JSP.
>
> Thank you.
>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>