Click here to Skip to main content
12,953,541 members (50,264 online)
   

Java

 
AnswerRe: begin java Pin
ravi kumbhkar23-Sep-12 20:12
memberravi kumbhkar23-Sep-12 20:12 
AnswerRe: begin java Pin
Amarnath S24-Sep-12 5:48
memberAmarnath S24-Sep-12 5:48 
AnswerRe: begin java Pin
April Fans22-Dec-12 21:26
memberApril Fans22-Dec-12 21:26 
QuestionData grid view Pin
Member 944920221-Sep-12 20:09
memberMember 944920221-Sep-12 20:09 
AnswerRe: Data grid view Pin
Richard MacCutchan21-Sep-12 21:17
mvpRichard MacCutchan21-Sep-12 21:17 
QuestionMulti-part data in jsp forms Pin
Member 944821321-Sep-12 7:11
memberMember 944821321-Sep-12 7:11 
GeneralRe: Multi-part data in jsp forms Pin
Richard MacCutchan21-Sep-12 21:16
mvpRichard MacCutchan21-Sep-12 21:16 
GeneralRe: Multi-part data in jsp forms Pin
Sivaramakrishna.p22-Sep-12 5:20
memberSivaramakrishna.p22-Sep-12 5:20 
upload_file_multipale_html.jsp
-----------------------------------------
<%@page import="java.io.File"%>



<title>Multipale file upload by using apache.commons.fileupload



First name:

Last name:


Specify file:














--------------------------------------------
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 !!!!! Pin
mAzeem2220-Sep-12 21:29
membermAzeem2220-Sep-12 21:29 
AnswerRe: Need HELP !!!!! Pin
Richard MacCutchan21-Sep-12 3:17
mvpRichard MacCutchan21-Sep-12 3:17 
QuestionReading byte from COM Port Pin
mahesh waghmale20-Sep-12 20:07
membermahesh waghmale20-Sep-12 20:07 
AnswerRe: Reading byte from COM Port Pin
Richard MacCutchan20-Sep-12 21:04
mvpRichard MacCutchan20-Sep-12 21:04 
AnswerRe: Reading byte from COM Port Pin
jschell23-Sep-12 7:59
memberjschell23-Sep-12 7:59 
Questionconfgurate connexion with hibernate in ireport 4.7 Pin
ahmed karimi220-Sep-12 3:16
memberahmed karimi220-Sep-12 3:16 
AnswerRe: confgurate connexion with hibernate in ireport 4.7 Pin
TorstenH.20-Sep-12 19:20
memberTorstenH.20-Sep-12 19:20 
GeneralRe: confgurate connexion with hibernate in ireport 4.7 Pin
ahmed karimi223-Sep-12 22:36
memberahmed karimi223-Sep-12 22:36 
GeneralRe: confgurate connexion with hibernate in ireport 4.7 Pin
TorstenH.24-Sep-12 2:17
memberTorstenH.24-Sep-12 2:17 
QuestionRS232(16) Communication in java Pin
mahesh waghmale19-Sep-12 18:26
membermahesh waghmale19-Sep-12 18:26 
AnswerRe: RS232(16) Communication in java Pin
Richard MacCutchan19-Sep-12 21:20
mvpRichard MacCutchan19-Sep-12 21:20 
QuestionLucene - getting tokens for a given document Pin
jgrogan18-Sep-12 3:19
memberjgrogan18-Sep-12 3:19 
AnswerRe: Lucene - getting tokens for a given document Pin
Richard MacCutchan18-Sep-12 4:15
mvpRichard MacCutchan18-Sep-12 4:15 
GeneralRe: Lucene - getting tokens for a given document Pin
jgrogan18-Sep-12 4:29
memberjgrogan18-Sep-12 4:29 
GeneralRe: Lucene - getting tokens for a given document Pin
Richard MacCutchan18-Sep-12 4:42
mvpRichard MacCutchan18-Sep-12 4:42 
QuestionSpeech Recognition for greenfoot Pin
fadlimovic18-Sep-12 2:39
memberfadlimovic18-Sep-12 2:39 
AnswerRe: Speech Recognition for greenfoot Pin
Richard MacCutchan18-Sep-12 2:45
mvpRichard MacCutchan18-Sep-12 2:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    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
Web02 | 2.8.170525.1 | Last Updated 27 May 2017
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid