File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes handling html parameters in a jsp page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "handling html parameters in a jsp page" Watch "handling html parameters in a jsp page" New topic

handling html parameters in a jsp page

federico tonioni

Joined: Dec 16, 2002
Posts: 9
Hi to all!
I have the following code in a jsp page:

<% for (int i = 0; i < collectionArray.length; i++) {
<td width="18%"><a href="documentview.jsp?id=<%= collectionArray[i]%>"><%= collectionArray[i] %></a></td>
<td width="17%"><input type="checkbox" name="checkbox" value="<%= collectionArray[i] %>" >
catch (XMLDBException e) {
response.getWriter().println("adminstart.jsp Exception occured " + e.errorCode);
finally {
if (col != null) {

<input type="submit" name="choice" value="Delete Checked Collection" >

<form name="insertionForm" action="CollectionFormProcess" method=post >
<input type="submit" name="choice" value="Insert a collection name" >
<input type="text" name="collectionName" >
iwould like to know if it is possible to get the value of the submit html variable...
i would like to know if it possible to write the following:
<% if choice.value.equals(null) choice.value= "Insert a collection name" %>
my problem is that the servlet rises a NullPointerException when an user write some text in the collectionName field and press Enter because the servlet makes an if-clause on the "choice" value
if (request.getParameter("choice").equals("Insert a collection name")) {
//some code
// other code

any help would be highly appreciated
thank you in advance
Dominic Paquette
Ranch Hand

Joined: Dec 13, 2002
Posts: 64
From what I see in the code you posted, when you call
it should return the string "Insert a collection name", I tried it and it works.
are you sure the exception is comming from that statement?
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
You are calling equals on null. Try this...
<% if choice.value == null) choice.value= "Insert a collection name" %>

So much trouble in the world -- Bob Marley
Dominic Paquette
Ranch Hand

Joined: Dec 13, 2002
Posts: 64
I don't think that calling equals with a null parameter throws an exception, I think it simply returns false
Asher Tarnopolski
Ranch Hand

Joined: Jul 28, 2001
Posts: 260
dominic is right. it just returns false.
to the main questio: can you please post your code as it is in your java/jsp file?

Asher Tarnopolski
I agree. Here's the link:
subject: handling html parameters in a jsp page
It's not a secret anymore!