Click here to Skip to main content
       

Java

 
AnswerRe: begin java Pinmemberravi kumbhkar23-Sep-12 20:12 
AnswerRe: begin java PinmemberAmarnath S24-Sep-12 5:48 
AnswerRe: begin java [modified] PinmemberApril Fans22-Dec-12 21:26 
QuestionData grid view PinmemberMember 944920221-Sep-12 20:09 
AnswerRe: Data grid view PinmvpRichard MacCutchan21-Sep-12 21:17 
QuestionMulti-part data in jsp forms PinmemberMember 944821321-Sep-12 7:11 
GeneralRe: Multi-part data in jsp forms PinmvpRichard MacCutchan21-Sep-12 21:16 
GeneralRe: Multi-part data in jsp forms PinmemberSivaramakrishna.p22-Sep-12 5:20 
upload_file_multipale_html.jsp
-----------------------------------------
<%@page import="java.io.File"%>
<html>
 
<head>
<title>Multipale file upload by using apache.commons.fileupload</title>
</head>
<body>
<form action="upload_file_multipale.jsp" method="post" name="form1" id="form1">
First name: <input type="text" name="fname">

Last name: <input type="text" name="lname">


Specify file: <input name="file" type="file" id="file">

<input type="submit" name="Submit" value="Submit files"/>







 

</form>
</body>
</html>
--------------------------------------------
upload_file_multipale.jsp
-------------------------------------------
<%@ page contentType="text/html; charset=iso-8859-1" language="java" errorPage="" %>
<%@ page import="java.util.List"%>
<%@ page import="java.util.Iterator"%>
<%@ page import="java.io.File"%>
<%@ page import="org.apache.commons.fileupload.*"%>
<%@ page import="org.apache.commons.fileupload.disk.DiskFileItemFactory"%>
<%@ page import="org.apache.commons.fileupload.servlet.ServletFileUpload"%>
<%@ page import="org.apache.commons.io.FilenameUtils"%>
<%@ page import="org.apache.commons.fileupload.*"%>
<%@ page import="java.lang.Exception"%>
 

<center>
            <p><b>First Name:</b>
   <%= request.getParameter("fname")%>
<p><b>First Name:</b>
   <%= request.getParameter("lname")%>
 
            <%
 
                 String itemName="";
                boolean isMultipart = ServletFileUpload.isMultipartContent(request);
 
                 if (!isMultipart){
                        out.println("The Form is not Multipart!!!!!");
                 }
                else
                {
                         FileItemFactory  factory = new DiskFileItemFactory();
                         ServletFileUpload upload = new ServletFileUpload(factory);
                         List items = null;
                         try {
                                        items = upload.parseRequest(request);
                         } catch (FileUploadException  e) {
                                        out.println(e.toString());
                         }
                                                Iterator itr = items.iterator();
 
                                                while (itr.hasNext()) {
                                                            FileItem item = (FileItem) itr.next();
                                                            if (item.isFormField()){
                                                                         String name = item.getFieldName();
                                                                         String value = item.getString();
                                                            }
                                                            else {
                                                                        try {
                                                                                     itemName = item.getName();
                                                                                    itemName = FilenameUtils.getName(itemName);
                                                                                    //out.println(itemName);

    File savedFile = new File(config.getServletContext().getRealPath("/")+"uploadedFiles/"+itemName);
                       item.write(savedFile);
                       session.setAttribute("FileName",itemName);
 
                                                                       } catch (Exception e) {
                                                                                                out.println(e.toString());
                                                                        }
                                                            }
                                                }
                                    }
 

 
   %>
<table align="center" border="1">
           <td>
 
               <%
 
                     String FileName = (String)session.getAttribute("FileName");
                     File savedFile = new File(request.getContextPath() +"/uploadedFiles/"+FileName  );
 
                %>
                <img src="<%=savedFile %>" width="800" height="800">
 
           </td>
       </table>

 
So when I am trying to run these files I can successfully upload my image and display it back but I cannot get the values that I had mentioned in the text fields and it is displaying null
QuestionNeed HELP !!!!! PinmembermAzeem2220-Sep-12 21:29 
AnswerRe: Need HELP !!!!! PinmvpRichard MacCutchan21-Sep-12 3:17 
QuestionReading byte from COM Port Pinmembermahesh waghmale20-Sep-12 20:07 
AnswerRe: Reading byte from COM Port PinmvpRichard MacCutchan20-Sep-12 21:04 
AnswerRe: Reading byte from COM Port Pinmemberjschell23-Sep-12 7:59 
Questionconfgurate connexion with hibernate in ireport 4.7 Pinmemberahmed karimi220-Sep-12 3:16 
AnswerRe: confgurate connexion with hibernate in ireport 4.7 PinmemberTorstenH.20-Sep-12 19:20 
GeneralRe: confgurate connexion with hibernate in ireport 4.7 Pinmemberahmed karimi223-Sep-12 22:36 
GeneralRe: confgurate connexion with hibernate in ireport 4.7 PinmemberTorstenH.24-Sep-12 2:17 
QuestionRS232(16) Communication in java Pinmembermahesh waghmale19-Sep-12 18:26 
AnswerRe: RS232(16) Communication in java PinmvpRichard MacCutchan19-Sep-12 21:20 
QuestionLucene - getting tokens for a given document Pinmemberjgrogan18-Sep-12 3:19 
AnswerRe: Lucene - getting tokens for a given document PinmvpRichard MacCutchan18-Sep-12 4:15 
GeneralRe: Lucene - getting tokens for a given document Pinmemberjgrogan18-Sep-12 4:29 
GeneralRe: Lucene - getting tokens for a given document PinmvpRichard MacCutchan18-Sep-12 4:42 
QuestionSpeech Recognition for greenfoot Pinmemberfadlimovic18-Sep-12 2:39 
AnswerRe: Speech Recognition for greenfoot PinmvpRichard MacCutchan18-Sep-12 2:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web04 | 2.8.140721.1 | Last Updated 29 Jul 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid