Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / January 2007

Tip: Looking for answers? Try searching our database.

More problems with request.getParameter == null

Thread view: 
Teresa Robinson - 30 Jan 2007 21:52 GMT
Hello again,

(hopefully the follow-ups have been taken care of: had to go into
agent.ini to get rid of the thing)

With your help, I was able to get the file upload code to work.  Thank
you!

My new problem is in allowing the user to delete an uploaded file by
clicking a button at the end of the HTML row that contains that file
name.  IE:

...
<%
for (int i=0; i < histid.size(); i++) {
html_hist = html_hist +
"<tr>" +
"<td>" +
   filename
"</td>" +
"<td style=padding-left:0.3cm; padding-top:0.5cm>" +
  "<form action=\"deleteconfirm.jsp\" method=\"POST\"
    enctype=\"application/x-www-form-urlencoded\">"  +
     "<input type=\"submit\" name=\"delete\" value=\"Delete\" />" +
     "<input type=\"hidden\" name=\"filename\" value= " +
    filename + "> " +
     "<input type=\"hidden\" name=\"hist_id\" value= " +
    histid + "> " +
     "<input type=\"hidden\" name=\"username\" value= " +
    username + "> " +
     "<input type=\"hidden\" name=\"state_name\" value= " +
    state_name + "> " +
   "</form>" +
"</td>" +
"</tr>";
}
...
%>
...

Clicking on the Delete button takes the user to a confirm page,
deleteconfirm.jsp, IE:

<%

   String username = request.getParameter("username");
   String filename = request.getParameter("filename");
   String hist_id = request.getParameter("hist_id");
   String state_name = request.getParameter("state_name");
           
%>
...
<form action="deleteuploadedfile" method="POST"
    enctype="multipart/form-data">
 <table cellspacing="0" cellpadding="0" border="0" width="100%">
   <tr>
     <td>
         Delete this file? (<%= filename %>)
     </td>
     <td>
         <input type="hidden" name="username"
        value= <%= username %> >
         <input type="hidden" name="filename" value= <%= filename %>>
         <input type="hidden" name="hist_id" value= <%= hist_id %>>
         <input type="hidden" name="state_name"
        value= <%= state_name %> >
         <input type="submit" name="delete" value="Delete"/>
     </td>
   </tr>
   <tr>
     <td>
         Cancel?&nbsp;&nbsp;&nbsp;&nbsp;
     </td>
     <td>
         <input type="hidden" name="cancel" value="cancel" >
         <input type="submit" name="cancel" value="Cancel"/>
     </td>
   </tr>
 </table>
</form>
...

The deleteuploadedfile servlet is then supposed to delete the file
based on these parameters:

       String filename = request.getParameter("filename");
       String hist_id = request.getParameter("hist_id");
       String username = request.getParameter("username");

but the parameters are null.

In debugging, I have found that the values somehow don't come through
to the servlet when the user clicks the Delete button.  They are
correct throughout the whole process until then.

Does it have something to do with having many Delete buttons in the
Form action in deleteconfirm.jsp?  I am blind at this point, so any
help is appreciated.

(and I know, you shouldn't do out.writes in jsp, it's what I thought
of at the time)

Thank you all in advance.
Signature

Teresa Robinson
General Dynamics
 Information Technology
Teresa.Robinson [at] gdit [dot] com

Manish Pandit - 30 Jan 2007 22:10 GMT
> Hello again,
>
[quoted text clipped - 104 lines]
>   Information Technology
> Teresa.Robinson [at] gdit [dot] com

Get rid of enctype="multipart/form-data" from your form tag. Since you
are not uploading any files in the forms, this is not needed. Using
enctype of multipart renders the request to be multipart, which
explains getParameter() returning null.

-cheers,
Manish
Teresa Robinson - 31 Jan 2007 14:10 GMT
>> Clicking on the Delete button takes the user to a confirm page,
>> deleteconfirm.jsp, IE:
>> ...
>> <form action="deleteuploadedfile" method="POST"
>>         enctype="multipart/form-data">

>> </form>
>> ...
[quoted text clipped - 7 lines]
>>
>> but the parameters are null.

>Get rid of enctype="multipart/form-data" from your form tag. Since you
>are not uploading any files in the forms, this is not needed. Using
>enctype of multipart renders the request to be multipart, which
>explains getParameter() returning null.

Goodness, you are right, I didn't see that.  I knew it was some little
thing I wasn't seeing.

Thank you so much, both of your comments have been spot on.

Signature

Teresa Robinson
General Dynamics
 Information Technology
Teresa.Robinson [at] gdit [dot] com



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.