Form Processing Problem

Form Processing Problem

I am trying to create a Circular Page. This is the Code where the circular is updated and asks for Circular Reference number and date.

<%@ page import="java.io.*" %>
<%
        //to get the content type information from JSP Request Header
        String contentType = request.getContentType();
        //here we are checking the content type is not equal to Null and
 //as well as the passed data from mulitpart/form-data is greater than or
 //equal to 0
        if ((contentType != null) && (contentType.indexOf("multipart/form-data") >= 0)) {
                DataInputStream in = new DataInputStream(request.getInputStream());
                //we are taking the length of Content type data
                int formDataLength = request.getContentLength();
                byte dataBytes[] = new byte[formDataLength];
                int byteRead = 0;
                int totalBytesRead = 0;
                //this loop converting the uploaded file into byte code
                while (totalBytesRead < formDataLength) {
                        byteRead = in.read(dataBytes, totalBytesRead,formDataLength);
                        totalBytesRead += byteRead;
                        }
                                        String file = new String(dataBytes);
                //for saving the file name
                String saveFile = file.substring(file.indexOf("filename=\"") + 10);
                saveFile = saveFile.substring(0, saveFile.indexOf("\n"));
                saveFile = saveFile.substring(saveFile.lastIndexOf("\\") + 1,saveFile.indexOf("\""));

                File f=new File("C:/Program Files/Apache Software Foundation/Apache Tomcat 7.0.34/bin/UploadedFiles/"+saveFile); //the changed code->1  

                int lastIndex = contentType.lastIndexOf("=");
                String boundary = contentType.substring(lastIndex + 1,contentType.length());
                int pos;
                //extracting the index of file 
                pos = file.indexOf("filename=\"");
                pos = file.indexOf("\n", pos) + 1;
                pos = file.indexOf("\n", pos) + 1;
                pos = file.indexOf("\n", pos) + 1;
                int boundaryLocation = file.indexOf(boundary, pos) - 4;
                int startPos = ((file.substring(0, pos)).getBytes()).length;
                int endPos = ((file.substring(0, boundaryLocation)).getBytes()).length;
                // creating a new file with the same name and writing the content in new file

                FileOutputStream fileOut = new FileOutputStream(f);

                //FileOutputStream fileOut = new FileOutputStream(saveFile);
                fileOut.write(dataBytes, startPos, (endPos - startPos));
                fileOut.flush();
                fileOut.close();
                                %><Br><table border="2"><tr><td><b>You have successfully  upload the file by the name of:</b>
                                            <!--<br><a href="viewFiles.jsp">View Files</a>-->
                                            **<br><br><br><form action="viewFiles.jsp" method="POST">
Circular Reference#: <input type="text" name="first_name">
<br />
Circular Date: <input type="text" name="last_name" />
<input type="submit" value="Submit" />
</form>
                <% out.println(saveFile); %></td></tr></table> 
                <%
                }
%>

and below is the code where it will view the inputs taken like Circular Reference and date viewFiles.jsp

<%@ page import="java.io.*"%>
<html>
<table>
<tr><th>Circular Name</th><th>Download File</th>
<%
File f = new File("C:/Program Files/Apache Software Foundation/Apache Tomcat 7.0.34/bin/UploadedFiles/");
        File[] files = f.listFiles();
        for(int i=0;i<files.length;i++){
            String name=files[i].getName();
            String path=files[i].getPath();
%>
<tr><td><%= request.getParameter("first_name")%></td><td><%= request.getParameter("last_name")%></td><td><%=name%></td><td><a href="download.jsp?f=<%=path%>">Download File</a></td></tr>
     <%
        }
%>
</table>
</html>

The problem while displaying according to the code.. If we upload 3 files for all the files it will display the same circular date and reference as the variable is not unique for each inputs taken. Kindly help me, to take unique inputs from forms and the inputs will be saved when I open viewFiles.jsp. So that I can enter new Circular Reference and Date for other files uploaded and save it, so that it can be displayed in columns like

Circular reference Circular Date Files Download Files

View Answers









Related Tutorials/Questions & Answers:
Form Processing Problem
Form Processing Problem  I am trying to create a Circular Page... to Null and //as well as the passed data from mulitpart/form-data is greater...; (contentType.indexOf("multipart/form-data") >= 0)) { DataInputStream
PROBLEM IN FORM VALIDTION
PROBLEM IN FORM VALIDTION  i applied validation IN THIS JSP PAGE.if i... the PROBLEM is that after i press OK on validation prompt,the page goes...; } </script> </head> <body> <form name="form" method="post
Advertisements
PHP Sticky form problem
PHP Sticky form problem  I have done the full coding of a sticky form.... Please see my coding below...and advice me what is the problem, and what...;/head> <body> <h1>Simple Calculator</h1> <form action
PHP Sticky form problem
PHP Sticky form problem  I have done the full coding of a sticky form.... Please see my coding below...and advice me what is the problem, and what...> <form action="simple_calculator.php" method="post"> <p>Number 1
Form processing using Bean
Form processing using Bean In this section, we will create a JSP form using bean ,which will use a class file for processing. The standard way of handling... to each field in the form.  The class fields must have "setters"
Problem in enctype="multipart/form-data" in JSP
Problem in enctype="multipart/form-data" in JSP  im using a page... the file itself when i click the submit button. im using enctype="multipart/form-data" in this form. i also using the commons-fileupload-1.2.2.jar file for getting
Problem when resizing the form - Swing AWT
Problem when resizing the form  Hi, I am facing a problem when resizing the form. I have a JTextPane on the JInternalFrame which occupy all the form space at initial stage. we have a button to add a new JTextPane on the form
New Problem in Form Resizing - Swing AWT
New Problem in Form Resizing  Hi, I am using a MDI application...)); The problem is arising when the user resizes the form. The EditorPane(old... the form? This problem is occuring only the components which are added
Problem submitting a struts form containing a dojo script - Struts
Problem submitting a struts form containing a dojo script  Hello there, Is there any way to make use of dojo with struts 1 ? Actually, I'm facing a problem submitting a struts form containing a dojo script for a dynamic
this code will be problem it display the error again send jsp for registration form
this code will be problem it display the error again send jsp for registration form  I AM ENTERING THE DETAILS OFTER IT DISPLAY THE ERROR PLEASE.... 1)register.jsp <html> <form method="post" action="insert.jsp"> <
this code will be problem it display the error again send jsp for registration form
this code will be problem it display the error again send jsp for registration form  I AM ENTERING THE DETAILS OFTER IT DISPLAY THE ERROR PLEASE.... 1)register.jsp <html> <form method="post" action="insert.jsp"> <
form
form   Can I prevent a form from being submitted again
data processing is
data processing is   data processing is   Data processing is associated with commercial work. Data processing is also referred as Information System. Data processing is basically used for analyzing, processing
image Processing
image Processing   BCIF Image Compresssion Algorithm s alossless image Compression algorithm ,Pleas Help Me weather it can support only 24 bit bmp images
jsp form
jsp form  hi sir, one got one got in jsp form after entering the data into the form the data is not saving in the database i will send you code of two forms if dnt understand my problem
Steps for the payment gateway processing?
Steps for the payment gateway processing?  Steps for the payment gateway processing
ModuleNotFoundError: No module named 'processing'
ModuleNotFoundError: No module named 'processing'  Hi, My Python... 'processing' How to remove the ModuleNotFoundError: No module named 'processing' error? Thanks   Hi, In your python environment you
request processing in servlets
request processing in servlets  how request processing is done in servlets and jsp   Please visit the following links: JSP Tutorials Servlet Tutorials Here, you will find several examples of processing request
PHP form
PHP form  Hi Sir/Madam, I am developing an attendance form using php... am adding one textfield to enter the Attendance... The problem is I am... form and update them to respective coloumn... Please any one help mo out please
Processing Sequence of DispatcherServlet
In this section, you will get to know about the processing sequence of DispatcherServlet
Problem in enctype=
Problem in enctype=  im using a page which is in JSP. i have some... the submit button. im using enctype="multipart/form-data" in this form. i also using.... but the problem is the uploaded file is not stored in the prefered folder. i printed
problem:struts code - Struts
problem:struts code  Hi, Am using struts1.2.I wrote a form(dynavalidator form)with validation after completing the form if we press submit its call the action class,in action class i gave forward to same form,the problem is if i
Abort JSP processing
Abort JSP processing  Can I just abort processing a JSP?   Yes. You can put a return statement to abort JSP processing
The product of data processing is
The product of data processing is   The product of data processing is 1. Data 2. Information 3. Software 4. Computer 5. All of the above   Answer: 3. Software
Ajax form element - Ajax
Ajax form element  I have problem in passing a value into form feild using ajax. I want to get the value is as a parameter. Can some one help me plz
Speech Processing - Java Beginners
Speech Processing  I want to implement Speech Processing in Java. How can I do It? Please Answer me
Process HTML FORM data
Process HTML FORM data  Can a JSP page process HTML FORM data?   Yes. Preemptive termination of request processing on an error condition... you want to terminate further processing
form validation
form validation  how the form validation is done in jsf form using javaScript
text processing program
text processing program  how can i compare letter by letter? what i was trying to do is a program that can define what is root word,prefix and suffix. plz help
problem with cookie - Struts
problem with cookie  struts cookies response - Hii, I am a beginner in struts..Well, I try to add username and group(or whatever) to a cookie but not able to access the cookie value in the next page after submitting the form
problem related to onSubmit() method
problem related to onSubmit() method  Hello, I am developing application.when i submit form at that time formBacking() method is call...Instead of that onSubmit() should have to call .... please help me
uploading problem
;font size="+3" color="white"> <TABLE> <tr><td><form...; <TABLE> <TR><TD><form name="form2" action...(); } } } } %> my problem...: firstly
problem in onlinetest...
problem in onlinetest...  hi, my code getting the problem is ,when user leave a question then the server puts error... pls help me
jsp problem
jsp problem  problem:::::::: On JSP form ,when i insert data in text... and get assign to other field on that form........ when data is assign to other field on that form at that time firstly inserted data is not present on that form
dropdownbox-form - Struts
dropdownbox-form  i have a problem i was create combobox using... form and i use that fields for database insert if any one understand my problem give reply and send to [email protected] waiting for reply
Problem in jsp.
Problem in jsp.  hello friends, I have a problem in jsp.I want to insert data, which is given by user through a html page into a table.And the table... in advance.   1)form.html: <html> <form method="post
Problem in jsp.
Problem in jsp.  hello friends, I have a problem in jsp.I want to insert data, which is given by user through a html page into a table.And the table... in advance.   1)form.html: <html> <form method="post
Problem in jsp.
Problem in jsp.  hello friends, I have a problem in jsp.I want to insert data, which is given by user through a html page into a table.And the table... in advance.   1)form.html: <html> <form method="post
HTML form - Java Beginners
(form1 and form 2)with several fields in html. When i click the submit button, it validates all fields then moves to form2. i have a problem with form navigation. i... friend, Code to help in solving the problem : when You submit the form
logout problem
me out of this... the problem is -- when i logout , the user goes... he has come from .. please get me out of this problem thanks.   Use...;/head> <br> <body Bgcolor ="#0099cc"><hr><hr> <form
Hint: Java session problem - WebSevices
Hint: Java session problem  Hai, My problem is : In a jsp form i have several case-form links. If i open one case-form and navigate through its form..., it is carryin to the second form too..How to avoid this problem? Please suggest
print a form of *
print a form of *   * *** ***** ******* ********* ******* ***** *** *   Post the format properly
problem in validation
problem in validation  sir/madam, i m using struts-1.3.10. i m getting a problem my properties file is not found.... while i hav configuired it in struts-config.xml file, likeADS_TO_REPLACE_1 thanks n regards himanshu
javascript problem
javascript problem  hi guys My problem is that I am using radio button for yes or no but i want to do that if I press yes button then enter... enter please help me this problem
ModuleNotFoundError: No module named 'List_Processing'
ModuleNotFoundError: No module named 'List_Processing'  Hi, My... named 'List_Processing' How to remove the ModuleNotFoundError: No module named 'List_Processing' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'processing-spinner'
ModuleNotFoundError: No module named 'processing-spinner'  Hi, My... named 'processing-spinner' How to remove the ModuleNotFoundError: No module named 'processing-spinner' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'signal-processing'
ModuleNotFoundError: No module named 'signal-processing'  Hi, My... named 'signal-processing' How to remove the ModuleNotFoundError: No module named 'signal-processing' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'task-processing'
ModuleNotFoundError: No module named 'task-processing'  Hi, My... named 'task-processing' How to remove the ModuleNotFoundError: No module named 'task-processing' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'text_processing'
ModuleNotFoundError: No module named 'text_processing'  Hi, My... named 'text_processing' How to remove the ModuleNotFoundError: No module named 'text_processing' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'word-processing'
ModuleNotFoundError: No module named 'word-processing'  Hi, My... named 'word-processing' How to remove the ModuleNotFoundError: No module named 'word-processing' error? Thanks   Hi, In your python

Ads