-----------------------------
Please read the FAQ!
<http://java.apache.org/faq/>
-----------------------------

Dmitry Melekhov wrote:

> -----------------------------
> Please read the FAQ!
> <http://java.apache.org/faq/>
> -----------------------------
>
> I use JServ 1.0 with gnujsp 0.9.10.
>
> When  I execute following jsp code:
> <%=request.getParameterValues("todo")[0]%>
> <%
> switch (sess.getState()) {
> case 0:{%>
> <a href="main.jsp?todo=list">NieniYae</a>
> <a href="main.jsp?todo=add">Aiaaaeou</a>
> <BR>
> <%}
>
> without parameter todo in url refs don't occure :(
> If parameter exists all works ok.
> Why? And how to get it working without parameter?
>

If you call this code without passing any values for the "todo"
parameter, you will get a null pointer exception from the first line.
The reason is that getParameterValues() will return null in that case.

You might want to change the first line to something like this:

<%
  String todo = null;
  String values[] = request.getParameterValues("todo");
  if (values != null)
    todo = values[0];
%>

and the todo string will either contain the first occurrence of this
parameter, or null if it was not specified.

>
> Dmitry Melekhov
> (aka 2:5050/11.23@fidonet)
> http://www.aspec.ru/~dm
>

Craig McClanahan




--
--------------------------------------------------------------
Please read the FAQ! <http://java.apache.org/faq/>
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Archives and Other:  <http://java.apache.org/main/mail.html>
Problems?:           [EMAIL PROTECTED]

Reply via email to