Current Position:Home > Problem in getting the parameters from teh form html with upload file

Problem in getting the parameters from teh form html with upload file

Update:10-11Source: network consolidation
Advertisement
I have used the jspsmartupload package:
the html file:
<HTML>
<BODY BGCOLOR="white">
<H1>jspSmartUpload : Sample 5</H1>
<HR>
<form METHOD="POST" ACTION="sample5.jsp"
NAME="PW" ENCTYPE="multipart/form-data">
<table CELLSPACING="0" CELLPADDING="3" BORDER="1" WIDTH="474">
<!-- FILE -->
<!-- TEXT -->
<tr>
<td width="150">
<div align="left">
<p><small><font face="Verdana">Text :  </font></small>
</div>
</td>
<td width="324"><small><font face="Verdana">
<input TYPE="TEXT" name="myText" value="">
<br>
</font></small></td>
</tr>
<!-- TEXTAREA -->
<tr>
<td width="150">
<div align="left">
<p><small><font face="Verdana">Text Area :  </font></small>
</div>
</td>
<td width="324"><small><font face="Verdana">
<textarea name="myTextArea" rows="4" value=""></textarea>
<br>
</font></small></td>
</tr>
<!-- PASSWORD -->
<tr>
<td>
<div align="left">
<p><small><font face="Verdana">PassWord :  </font></small>
</div>
</td>
<td><small><font face="Verdana">
<input TYPE="PASSWORD" name="myPASSWORD" value="">
<br>
</font></small></td>
</tr>
<!-- HIDDEN -->
<tr>
<td>
<div align="left">
<p><small><font face="Verdana">Hidden :  </font></small>
</div>
</td>
<td><small><font face="Verdana">
<input TYPE="hidden" name="myHidden" value="hidden">
<br>
</font></small></td>
</tr>
<tr>
<td><small><font face="Verdana">Select a first file : 
</font></small></td>
<td><small><font face="Verdana">
<input type="file" name="FILE1">
</font></small></td>
</tr>
<tr>
<td><small><font face="Verdana">Select a second file : </font></small></td>
<td><small><font face="Verdana">
<input type="file" name="FILE2">
</font></small></td>
</tr>
<!-- CHECKBOX -->
<tr>
<td>
<div align="left">
<p><small><font face="Verdana">CheckBox :  </font></small>
</div>
</td>
<td><small><font face="Verdana">
<input TYPE="CHECKBOX" name="myCheckBox" value="Value 1">
Value 1<br>
<input TYPE="CHECKBOX" name="myCheckBox" value="Value 2">
Value 2<br>
<input TYPE="CHECKBOX" name="myCheckBox" value="Value 3">
Value 3<br>
</font></small></td>
</tr>
<!-- RADIO -->
<tr>
<td>
<div align="left">
<p><small><font face="Verdana">Radio :  </font></small>
</div>
</td>
<td><small><font face="Verdana">
<input TYPE="radio" name="radio" value="Value 1">
Value 1<br>
<input TYPE="radio" name="radio" value="Value 2">
Value 2<br>
<input TYPE="radio" name="radio" value="Value 3">
Value 3<br>
</font></small></td>
</tr>
<!-- SELECT -->
<tr>
<td>
<div align="left">
<p><small><font face="Verdana">Simple Select :  </font></small>
</div>
</td>
<td><small><font face="Verdana">
<SELECT name="mySimpleSelect" >
<OPTION value="Value 1">Value 1</OPTION>
<OPTION value="Value 2">Value 2</OPTION>
<OPTION value="Value 3">Value 3</OPTION>
</SELECT>
<br>
</font></small></td>
</tr>
<!-- SELECT MULTIPLE -->
<tr>
<td>
<div align="left">
<p><small><font face="Verdana">Multiple Select :  </font></small>
</div>
</td>
<td><small><font face="Verdana">
<SELECT multiple name="myMultSelect" >
<OPTION value="Value 1">Value 1</OPTION>
<OPTION value="Value 2">Value 2</OPTION>
<OPTION value="Value 3">Value 3</OPTION>
</SELECT>
<br>
</font></small></td>
</tr>
<!-- SUBMIT -->
<tr>
<td colspan="2" width="474">
<div align="center">
<center>
<p><small><font face="Verdana">
<input
TYPE="Submit">
</font></small>
</center>
</div>
</td>
</tr>
</table>
</form>
</BODY>
</HTML>
the jsp file :
<%@page language="java" import="com.jspsmart.upload.*"%>
<%@page import="java.util.*"%>
<jsp:useBean id="myUpload" scope="page" class="com.jspsmart.upload.SmartUpload" />
<HTML>
<BODY BGCOLOR="white">
<H1>jspSmartUpload : Sample 5</H1>
<HR>
<%
     // Initialization
     myUpload.initialize(pageContext);
     // Upload
     myUpload.upload();          
     // Files
     out.println("<BR><STRONG>Display information about Files</STRONG><BR>");
     out.println("Number of files = " + myUpload.getFiles().getCount() + "<BR>");
     //out.println("Total size (bytes) = " + myUpload.getFiles().getSize() +"<BR>");
     for (int i=0;i<myUpload.getFiles().getCount();i++){
          out.print(myUpload.getFiles().getFile(i).getFieldName());
          if (!myUpload.getFiles().getFile(i).isMissing())
               out.print(" = " + myUpload.getFiles().getFile(i).getFileName() + " (" + myUpload.getFiles().getFile(i).getSize() + ")");
               myUpload.getFiles().getFile(i).saveAs("/upload/" + myUpload.getFiles().getFile(i).getFileName());
          else
               out.print(" = vide");          
          out.println("<BR>");
     // Request
     out.println("<BR><BR><STRONG>Display information about Requests</STRONG><BR>");
     // Retreive Requests' names
     java.util.Enumeration e = myUpload.getRequest().getParameterNames();
     // Retreive parameters
     while (e.hasMoreElements()) {
          String key = (String)e.nextElement();
          String[] values = myUpload.getRequest().getParameterValues(key);               
          // Browse the current parameter values
          for(int i = 0; i < values.length; i++) {
          out.print(key + " = ");
          out.print(values[i] + "<BR>");
%>
</BODY>
</HTML>
The result shown is:
jspSmartUpload : Sample 5
Display information about Files
Number of files = 2
FILE1 = path.txt (240)
FILE2 = WS_FTP.LOG (146)
Display information about Requests
radio = Value 2
mySimpleSelect = Value 1
myTextArea = test
myPASSWORD =
myMultSelect = Value 3
myHidden = hidden
myText = test
myCheckBox = Value 1
myCheckBox = Value 2
myCheckBox = Value 3
I would like to know if i want to get back the parameters from the form ,
is that i must use Enumeration.
Because i have tried request.getParameter() to get the value of radio button, textbox, checkbox and select menu, but it get the null values.
Also, the function of Enumeration does not get the values of parameter in sequence as html form. e.g.In the html file, the first parameters should be textbox,but it displays the radio button's values first.
How to solve the problem .
Thanks

The Best Answer

Advertisement
This sounds like a bug in the smart upload code. I have used this stuff before, but it's probably an older version, so maybe they broke something. Enumerations aren't usually guaranteed to keep things in any particular order. I would say for now, make a method to take the enumeration and a param name to find the value. And write to the JSPSmart people.
  • Problem in getting the parameters from teh form html with upload file Update:10-11

    I have used the jspsmartupload package: the html file: <HTML> <BODY BGCOLOR="white"> <H1>jspSmartUpload : Sample 5</H1> <HR> <form METHOD="POST" ACTION="sample5.jsp" NAME="PW" ENCTYP

  • Problem in upload file using oreilly classes Update:10-11

    Hi I stucked on a problem...... I want to upload file from html page....On this page I want only a upload button so that when I click on this button file will upload from my client m/c to server m/c.... I have code n all but browse button on html pag

  • Problem in uploading file Update:10-11

    I stucked on a problem...... I want to upload file from html page....On this page I want only a upload button so that when I click on this button file will upload from my client m/c to server m/c.... I have code n all but browse button on html page..

  • Urgent !!!!!!!!!!!!!Uploading File problem Update:11-30

    Hi I stucked on a problem...... I want to upload file from html page....On this page I want only a upload button so that when I click on this button file will upload from my client m/c to server m/c.... I have code n all but browse button on html pag

  • Problem with ASP "Create form wizard" or "Update form wizard" and "Upload file" Update:10-11

    Until now it used version 3,7 and dinamyc had never had problems with "Create form wizard" or "Update form wizard" and "Upload file" but now when I create the form and shipment a file leaves an error to me: Error: Error al bo

  • Problem while Binding multiple Parameters to View Object[Solved] Update:10-11

    Hello, I am facing problem while binding multiple parameters with different data types in View Object query. For example suppose I have following query in my view object. SELECT Header.ADDED_BY Header.BATCH_ID, FROM BATCH_HEADER Header WHERE :1='dept

  • Problem with SET GET parameters Update:10-11

    Hi all, I am facing a problem using SET and GET parameters. There is a Z transaction(Dialog program) where some fields of screen are having parameter ID's. That transaction is designed to diaplay/change status of only one inspection lot at a time. No

  • Problem with passing date parameters in cursor Update:10-11

    Is there any problem in passing date parameters and like clause as below CURSOR eftcursor(start_date DATE, end_date DATE, where_clause varchar2) IS select * from r_records where created_date between start_date and end_date and description like where_

  • ORA-01078: failure in processing system parameters LRM-00109: could not open parameter file '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initORA11G.ora' Update:10-11

    I have installed an Oracle 11gR2 on Oracle Linux Server 6.6 (Virtualbox). I have the users grid and oracle11g. Add groups and install grid infrastructure first as a grid user and install database as oracle user as in documentation successfully. I hav

  • What parameters should i pass inorder to upload an excel file in gui_upload Update:11-30

    what parameters should i pass inorder to upload an excel file in gui_upload Thanks in advance. Ahmed.check below program.... *& Report  UPLOAD_EXCEL                                                * *& Upload and excel file into an internal table u