Click here to Skip to main content
15,887,683 members
Home / Discussions / Java
   

Java

 
AnswerRe: begin java Pin
ravi kumbhkar23-Sep-12 20:12
ravi kumbhkar23-Sep-12 20:12 
AnswerRe: begin java Pin
Amarnath S24-Sep-12 5:48
professionalAmarnath S24-Sep-12 5:48 
AnswerRe: begin java Pin
April Fans22-Dec-12 21:26
April Fans22-Dec-12 21:26 
QuestionData grid view Pin
Member 944920221-Sep-12 20:09
Member 944920221-Sep-12 20:09 
AnswerRe: Data grid view Pin
Richard MacCutchan21-Sep-12 21:17
mveRichard MacCutchan21-Sep-12 21:17 
QuestionMulti-part data in jsp forms Pin
Sivaramakrishna.p21-Sep-12 7:11
Sivaramakrishna.p21-Sep-12 7:11 
GeneralRe: Multi-part data in jsp forms Pin
Richard MacCutchan21-Sep-12 21:16
mveRichard MacCutchan21-Sep-12 21:16 
GeneralRe: Multi-part data in jsp forms Pin
Sivaramakrishna.p22-Sep-12 5:20
Sivaramakrishna.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
-------------------------------------------
XML
<%@ 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>

Java



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