T
Teresa Robinson
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?
</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.
(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?
</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.