Two Laptop Bag*
The moose likes HTML, CSS and JavaScript and the fly likes cant get at it...like.  i feel like tantalus Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "cant get at it...like.  i feel like tantalus" Watch "cant get at it...like.  i feel like tantalus" New topic
Author

cant get at it...like. i feel like tantalus

Chris Pat
Ranch Hand

Joined: Aug 27, 2005
Posts: 156
Hello
In the code below for input type=file, the js onchange grabs the file location of the selected file, however when I post it it is not in either the session or request param. (Further below is the jsp). What is odd is when I use the DOM Inspector in Mozilla the #text element for the input element file1Name shows " " for the value. However the input element labeled path does show the correct value.

How do I get the value of the selected file into a parameter accessible by an action or jsp?



[CODE]
<%@ page errorPage="UploadReview_error.jsp" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/xml" prefix="x" %>

<jsp:useBean id="uploader" class="filesDM.helper.UploadBean" scope="session" />

<jsp:setProperty name="uploader" property="dir"
value="<%=application.getInitParameter(\"save-dir\")%>" />

<jsp:setProperty name="uploader" property="req" value="<%= request %>" />
<jsp:setProperty name="uploader" property="path" value="<%=request.getParameter("file")%>"/>
<%=request.getParameter("file") %>

<html>
<head><title>file uploads</title></head>
<body>
From the session the websiteID= <c ut value="${websiteID}" default="not in session"/><br />
From the session file1= <c ut value="${file1}" default="no file1 from session"/><br />
From the session file1Name= <c ut value="${file1Name}" default="no file1Name from session"/><br />
From the parameters varstatus= <c ut value="${param.varStatus}" default="not a parameter"/> state= <c ut value="${param.state}"/>.<br />
From the parameters file1= <c ut value="${param.file1}" default="no file1 from parameters"/><br />
From the parameters file1Name= <c ut value="${param.file1Name}" default="no file1Name from parameters"/><br />

<h2>Here is information about the uploaded files</h2>

<jsp:getProperty name="uploader" property="uploadedFiles" />


</body>
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Maybe it's a security feature? But anyway, you get the name of the file as part of the <input type="file"> entry, so I don't see why you are trying to duplicate that information in your request.
Chris Pat
Ranch Hand

Joined: Aug 27, 2005
Posts: 156
Originally posted by Paul Clapham:
Maybe it's a security feature? But anyway, you get the name of the file as part of the <input type="file"> entry, so I don't see why you are trying to duplicate that information in your request.


Hi Paul
That is the problem, I cant get it from the request.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

You need to parse the multipart request. There are some third party libraries to help you do that, like the Jakarta Commons FileUpload :
http://jakarta.apache.org/commons/fileupload/index.html

There's a tag library called "Xephyrus File Upload Tag Library", but I can't access their webpage...
[ May 29, 2006: Message edited by: Satou kurinosuke ]

[My Blog]
All roads lead to JavaRanch
 
 
subject: cant get at it...like. i feel like tantalus
 
Similar Threads
Problem of insert data into database
Problem iterating rows of a ResultSet with JSP
Wanting to Displaying Empty Data on Initial Search Page
Wanting to Displaying Empty Data on Initial Search Page
Spring with JSTL the expresion c:out value="${result}" not working