Click here to Skip to main content
12,395,593 members (60,489 online)
   

Java

 
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"%>
<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 !!!!! 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 

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.160721.1 | Last Updated 23 Jul 2016
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid