JSP : latest  JSTL, File Upload from web form Client to Server Question!

I understand that within a JSP, It is possible to read a file from the Client by opening a Stream somehow.
How do I code, within jsp/servlet (non tag) java code inside <% %>
blocks, WITHOUT openening a new connection to the URL, an InputStream from a client web browser form, from a file upload coded using
<input type="file" name="file1"/> ?
I have previously achieved this quite simply with a FileInputStream
with the previous version of JSTL.
How may I do this with the latest version of JSTL, with this index.jsp?
-with a simple text file.
-with a Binary file (with DataInputStream)?
<%--
Document : index
Created on : 27/01/2009, 3:08:32 PM
Author : Zachary Mitchell
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1 align="center">Hello World!</h1>
<form name="form1" method ="POST" >
<table align="center">
<tr>
<td>
<input name="file1" type="file" align="center"></input>
</td>
</tr>
<tr>
<td>
<input type="submit" value="submit" action="index.jsp" ></input>
</td>
</tr>
</table>
</form>
<!--*********************************************************************** -->
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@page import = "java.io.*" %>
<c:if test="${pageContext.request.method=='POST'}">
<%
File fileName = new File(request.getParameter("file1"));
out.println(fileName.toString());
FileInputStream stream = new FileInputStream(fileName);
out.println(stream.toString());
%>
</c:if>
<!--*********************************************************************** -->
</body>
</html>

If I have:
<!-- ***********************************************************************************-->
<form name="form1" method="POST" enctype="multipart/form-data">
<input name="file1" type="file"/>
<input name="submit1" type="submit" value="Submit" action="index.jsp"/>
</form>
<!-- ***********************************************************************************-->
and run this in an index.jsp, use browse to select my text file, and click SUBMIT.
I can use:
InputStreamReader reader = new InputStreamReader(new DataInputStream(request.getInputStream()))
BufferedReader bufferedReader = new BufferedReader(reader);
bufferedReader.readLine();...
However, these is some HTML/POST related content around what multiple readLine();
calls return.
Is there an easy way, like using "${param.file1}",
aside from [http://commons.apache.org/fileupload/|http://commons.apache.org/fileupload/],
maybe using servlet style code, to get the File contents from a remote Client,
to the remote Server servlet engine, AVOIDING ANY SUPERFLUOUS CONTENT,
using version 1.12 of the JSTL, JSP 2.0,Tomcat 6?
Just politely, yes, no, and how?
Edited by: Zac1234 on Jan 29, 2009 3:27 AM
Edited by: Zac1234 on Feb 1, 2009 8:29 PM

Similar Messages

  • Generate doc file through a web form (using Developer Server 6i)

    Can anyone tell me is it possible to make a web form generate a doc file on the middle tier (Developer Server machine)?

    sample usage:
      CALL FUNCTION 'HTTP_POST'
        EXPORTING
          ABSOLUTE_URI                = IM_OFX_CONTROL_DATA-ADDRESS
          REQUEST_ENTITY_BODY_LENGTH  = RESPONSE_ENTITY_BODY_LENGTH
          RFC_DESTINATION             = IM_OFX_CONTROL_DATA-HTTP_RFCDEST
          USER                        = IM_OFX_CONTROL_DATA-HTTP_USER
          PASSWORD                    = IM_OFX_CONTROL_DATA-HTTP_PASSWORD
          BLANKSTOCRLF                = 'X'
        IMPORTING
          STATUS_CODE                 = STATUS
          STATUS_TEXT                 = STATUS_TEXT
          RESPONSE_ENTITY_BODY_LENGTH = RLENGTH
        TABLES
          REQUEST_ENTITY_BODY         = LT_REQUEST
          RESPONSE_ENTITY_BODY        = RESPONSE
          RESPONSE_HEADERS            = LT_RESPONSE_HEADERS
          REQUEST_HEADERS             = LT_HTTP_HEADERS
       EXCEPTIONS
            OTHERS                      = 1.
    Refer the programs:
    LFPIFF02            
    LOFXALSU04          
    LPRGN_URL_RESPONSEU01
    LSBCCU01            
    LSFTPU09            
    for some idea.
    regards,
    ravi

  • File Upload from Webdynpro to R/3 Server

    Hi all
    We have a scenario. In that we want to upload any type of file (can be .txt, .pdf, .doc, .xls, .jpg, .gif etc.) to the R/3 server. We r using a FileUpload UI Element.
    The problem is we want to pass the contents of the file (any type of file) to the rfc.
    If anybody  knows the solution for this please help us.
    (It will be of great help if u give the code)
    Thanks & Regards
    Aparnna

    Hi Aparna,
    It happens becuse u r trying to access the byte array of the file in a loop.
    For small file it will not make any pblm, but for for big files, the loop may have to iterate millions of times which result in server hang.
    So dont try to access the byte array in loop in ur code. Try to pass the byte array u r getting as whole to RFC.
    Regards
    Fahad Hamsa

  • Attaching files to a web form

    please tell me how to attach files to a web form for uploading. i know how to make a page that just uploads a file. but before i do it, i have to attach files( sent by a pop-up window ) to a web form in a main window. There are some resources about uploading files, but not for attaching files to a web form... please help me...
    Thanks in advance...

    I gotcha!
    Try this:
    1) Open new window with file inputs within a std form.
    2) Have form submit to servlet
    3) Have servlet retrieve file(s) and save them in session.
    4) Have servlet spit out javascript to close popup window and refresh main page (which will then show some sort of verification that the files were received.
    5) When main form is submitted, retireve (and remove) files from the session and process.
    Hope that helps,

  • How to change/set the browser title from web forms (XP platform with SP2)

    I am running Form9i, I have set the browser windows title from Web Forms dynamically by using following method. However, when my PC has changed to XP, the function seems not work. Does anybody have same problem and how to solve it? Any suggestions would be appreciated.
    Add the Javascript code to your baseHTML file. For example,
    if you are using the basejini.htm:
    <HEAD><TITLE>%pageTitle%</TITLE>
    <script language="javascript1.2" type="text/javascript1.2">
    function Change(a) {    document.title=a;    } </script>
    </HEAD>
    In web Forms , call the javascript function with WEB.SHOW_DOCUMENT built.
    For Example the following code set the browser title with username . web.show_document('javascript:Change('||'"'|| get_application_property(USERNAME)||'"'||')','_self');
    Best Regards,
    Bowie

    Dear Frank,
    Thanks for your reply. Can you tell me in detail which built-in function in Webutil can set value in browser title ?
    Btw, is it possible for me to set parameter "separateFrame=True" in formsweb.cfg and set the form window title by using SET_WINDOW_PROPERTY(FORMS_MDI_WINDOW,TITLE,v_msg_string)?
    Best Regards,
    Bowie

  • File Upload in a Form

    I have a file upload in a form of mine.
    I can't style the upload to match the rest of my form. I have tried to target the id="FileAttachment" to no avail. I have tried adding classes and nothing responds.
    In Dreamweaver it shows as styled until it gets on the web.
    Here is the site: http://ubhape2remodel.businesscatalyst.com/careers
    Any Advice?
    Thanks!

    Thanks for the information.
    I cannot get it to work and I am unsure why.  I am not sure if I am not using the JS right or not adding something to the css. I am a bit confused.
    I am not all that good at javascript so I assume something here is off and I am just missing it.
    One other note: Is it possible to use my style of buttons and not an image (I would like the hover effect that I use on the buttons to apply to that one as well.) But not sure how this can be done or if it is possible.
    Any help would be very very much appreciated.
    http://ubhape2remodel.businesscatalyst.com/careers
    Thanks!

  • Audit Intersection fails from Web Form

    We have an HFM 9.3.1 application successfully integrated with FDM 9.3.1, in that when navigating to a base level intersection, which has been loaded by FDM, the audit intersection option allows a drill-through analysis to the correct FDM application / location.
    This feature works perfectly OK from right clicking a grid intersection and selecting Audit Intersection. However, if a web form is used to display the same intersection and the user selects Audit Intersection the following error message is generated :-
    System Error "The signed on token is no longer valid" the web screen also displays an error stating there are localization errors and that the action is empty or missing.
    Repeatedly performing the same operation from data grids and web forms results in the web form audit always failing and grid audit always succeeding.
    Looking at the URL parameters I can see that the two sets of actions sent to generate the FDM audit page are indeed different
    I have included the source "action" parameter from the IntersectionSummarybyLocation web page. (With line breaks to aid readability)
    Repeated successful Grid Audit
    action="IntersectionSummaryByLocation.aspx?
    SSO_TOKEN=NbD9qzBZXx%2B%2BFm%2BFySzSa7uCWdYLvOAI14GJ6%2B7kFhWT2YN4lvlRfQExBNUyOMBkvAX1%2F3sfkyyu%0A3Ej8JSWj14o4Gf380eNrEeCax4fMVO28wUniiwcCepjkb6kvNhLCsKc%2FEmTctCxxd1lUmGcnalfO%0Avmc7rwQyxBAu8FtPnrtmy5REje4Epw%3D%3D&amp;
    FDMAppName=TTGFDM&amp;
    ScenarioLabel=Actual&amp;
    YearLabel=2012&amp;
    PeriodLabel=Apr&amp;
    ViewLabel=%3CScenario%20View%3E&amp;
    EntityLabel=CPW0005&amp;
    ParentLabel=AOL&amp;
    ValueLabel=%3CEntity%20Currency%3E&amp;
    AccountLabel=PL50000&amp;
    ICPLabel=%5BICP%20None%5D&amp;
    Custom1Label=F6000&amp;
    Custom2Label=%5BNone%5D&amp;
    Custom3Label=C7142&amp;
    Custom4Label=%5BNone%5D" id="formMain">
    Repeated failed action from web form
    action="IntersectionSummaryByLocation.aspx?
    SSO_TOKEN=NbD9qzBZXx++Fm+FySzSa7uCWdYLvOAI14GJ6+7kFhWT2YN4lvlRfQExBNUyOMBkvAX1/3sfkyyu%0A3Ej8JSWj14o4Gf380eNrEeCax4fMVO28wUniiwcCepjkb6kvNhLCsKc/EmTctCxxd1lUmGcnalfO%0Avmc7rwQyxBAu8FtPnrtmy5REje4Epw==&amp;
    FDMAppName=TTGFDM&amp;
    ScenarioLabel=Actual&amp;
    YearLabel=2012&amp;
    PeriodLabel=Apr&amp;
    ViewLabel=%3CScenario+View%3E&amp;
    EntityLabel=CPW0005&amp;
    ParentLabel=AOL&amp;
    ValueLabel=%3CEntity+Currency%3E&amp;
    AccountLabel=PL50000&amp;
    ICPLabel=%5BICP+None%5D&amp;
    Custom1Label=F6000&amp;
    Custom2Label=%5BNone%5D&amp;
    Custom3Label=C7142&amp;
    Custom4Label=%5BNone%5D" id="formMain"
    It would appear that the format for characters is different and the SSO_TOKEN is differrent (although this maybe by design since the calling locations are different).
    I have checked that the Grid and Web Form operations are calling the same web page encoding of Unicode (UTF-8).
    Anybody got any idea why FORM functionality is failing to display the Audit Intersection?
    Kind regards
    Colin
    Edited by: Colin Lye on Sep 15, 2011 6:26 AM

    Applied Patches 9.3.1.1 thru to 9.3.1.4 (latest).
    Problem resolved. Audit Intersections now work from both Grid and Forms.
    Incidentally, both "Action" parameters from Grid and Form are now identical including the SSO_Token.

  • "Import from Text File" & "Upload from Clipboard" icon not appearng in F110

    Hi Experts,
    While making the payment to the vendors through TN F110, in "PARAMETER" screen just next to 'STATUS' screen, there is a vendor field for selection in range and just ahead of this there is an icon for multiple vendor selection ( Bold arrow mark ). If I click on that multiple vender selection icon ( on bold arrow mark ), an another screen opens for multiple selection for vendors. In this screen 'Enter, Copy, Delete etc' icons are appearing at the bottom of the screen but "Import from Text File" & "Upload from Clipboard" icon are not appearing there.
    Can you please let me know how to bring that icons there?
    Points would be awarded.
    Rgds,
    Shailesh

    Hi Ravi,
    I have not yet created anything and have just entered the parameter. In the multiple screen for vendors there are 5 fields for individual and 5 for range selection. Even you can put more than five range selections or individual selections by clicking on the page button but there I am not finding these two icons.
    Can you please check at your end and let me know if you are getting or what to do to bring those two icons in F110.
    Rgds,
    Shailesh

  • Differentiate file uploaded from explorer view in SharePoint

    Hello,
    I am working on event receiver which on item adding updates few fields of document in library if those are not empty. The code is working fine in new file, drag and drop but in explorer view, I am not getting afterproperties values except two default field
    values (vti_parserversion and vti_filesize). But in updating event we are getting those values.
    Is there any way to differentiate file uploaded using explorer view in event receiver? So that I can work on updating in case of explorer view.
    Thanks.

    Hi,
    According to your post, my understanding is that you want to differentiate file uploaded from explorer view in SharePoint 2013.
    I made a test in my environment, both the two ways(“new document” or “Open with explorer” ) to upload document, the AfterProperties only contains two default field values(vti_parserversion and vti_filesize) in
    ItemAdding method in event receiver.
    There are two steps occur when uploading a file to document library, the file is uploaded in the first step, then the list item properties will be modified in the second step. 
    So, it is recommended to update the fields of document in ItemUpdating
    method in event receiver.
    Best Regards
    Dennis Guo
    TechNet Community Support

  • Sending email from web forms (Forms 6i)

    Does anyone know how to send email using Outlook from web forms? I can get it working with client server but not with web forms.
    Thanks,
    Darcea Klein
    null

    Many ways to send a email:
    1. use Web.Show_Document(v_url, '_blank') to call a .asp or .php or .cgi page which can send email, attaching some message.
    2. use utl_smtp built_in in Oracle 8i, you can save this procedure in database, then call this procedure in your web form.
    PROCEDURE SEND_EMAIL (sender IN VARCHAR2,
    recipient IN VARCHAR2,
    message IN VARCHAR2)
    IS
    mailhost VARCHAR2(30) := 'smtp.aaaaa.com';
    mail_conn utl_smtp.connection;
    BEGIN
    mail_conn := utl_smtp.open_connection(mailhost, 25);
    utl_smtp.helo(mail_conn, mailhost);
    utl_smtp.mail(mail_conn, sender);
    utl_smtp.rcpt(mail_conn, recipient);
    utl_smtp.data(mail_conn, message);
    utl_smtp.quit(mail_conn);
    -- Handle the error
    END;
    GOOD LUCK

  • File uploads from Flex

    How do I enable CF to allow file uploads from Flex?

    You will need to set the accept attribute of the cffile tag
    to allow the mime type application/octet-stream.

  • Issue of invoke wf_engine function from web service client.

    hi,
    I want to update work flow item attribute from web service client through soa gateway. but got the below exception:
    Error Description Error occured while service was processing.
    Error Details oracle.apps.fnd.soa.util.SOAException: ServiceProcessingError: Exception returned from JCA Service Runtime. file:/pim/oracle/DEV/inst/apps/DEV_pimenv/soa/PLSQL/1318/SETITEMATTRTEXT.wsdl [ SETITEMATTRTEXT_ptt::SETITEMATTRTEXT(InputParameters) ] - WSIF JCA Execute of operation 'SETITEMATTRTEXT' failed due to: Error while processing an API interaction execution. An error occurred while processing the interaction for invoking the WF_ENGINE.SETITEMATTRTEXT API. Cause: oracle.tip.adapter.apps.AppsContextValidationException: Cannot set Context ; nested exception is: ORABPEL-11812 Error while processing an API interaction execution. An error occurred while processing the interaction for invoking the WF_ENGINE.SETITEMATTRTEXT API. Cause: oracle.tip.adapter.apps.AppsContextValidationException: Cannot set Context Check to ensure that the XML containing parameter data matches the parameter definitions in the XSD. Contact oracle support if error is not fixable. at oracle.apps.fnd.soa.provider.services.jca.JCAHandler.invoke(JCAHandler.java:173) at oracle.apps.fnd.soa.provider.services.jca.JCAHandler.handleRequest(JCAHandler.java:120)
    it indicate " cannot set context". but there is no method of wf_engine api to set it.
    Thanks,
    Rock

    Hi, Buddy,
    Did you fix your issue?
    Now, I have the same issue, EBS version is 12.1.3. Using Soapui invoking PL/SQL, then go back to SOA monitor to check the error message.
    Could you please give me some advises?
    Thanks,
    Jackie

  • Error when calling BPEL process from web service client

    I have created three projects here ,there're no problem when testing Composite Application(SynchronousSampleApplication) by test case inside this project.
    When I create a Java Application(SynchronousSampleApp),inside this project I've created a web service client from file WSDL of BPEL. After that, In Main class, I call an operation from web service client.But have the following error:
    Jul 17, 2008 4:48:22 PM synchronoussampleapp.Main main
    SEVERE: null
    java.rmi.RemoteException: HTTP transport error: java.net.MalformedURLException: For input string: "${HttpDefaultPort}"; nested exception is:
    HTTP transport error: java.net.MalformedURLException: For input string: "${HttpDefaultPort}"
    at SynSample.SynchronuosSamplePortType_Stub.synchronuosSampleOperation(SynchronuosSamplePortType_Stub.java:83)
    at synchronoussampleapp.Main.main(Main.java:24)
    Caused by: HTTP transport error: java.net.MalformedURLException: For input string: "${HttpDefaultPort}"
    at com.sun.xml.rpc.client.http.HttpClientTransport.invoke(HttpClientTransport.java:140)
    at com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.java:96)
    at SynSample.SynchronuosSamplePortType_Stub.synchronuosSampleOperation(SynchronuosSamplePortType_Stub.java:67)
    ... 1 more
    Please help me soon. Thanks very much!

    Can't anyone help me? I'm using Netbean 6.1 and Glassfish server.
    Do I need any additional plugin?

  • File upload to web server

    I need a little help with the file upload process in flex..
    I am trying to upload a file.. i had it where i would get a cgi-script url passing as the following
    filename="filename"&filedata="data of the file"
    then my cgi script "written in C" would read from standard in.. and write the info to a file...
    now i get the following..
    ------------KM7Ef1gL6Ij5cH2ae0ei4Ij5GI3Ef1
    Content-Disposition: form-data; name="Filename"
    Botanical Garden 239.JPG
    ------------KM7Ef1gL6Ij5cH2ae0ei4Ij5GI3Ef1
    Content-Disposition: form-data; name="Filedata"; filename="Botanical Garden 239.JPG"
    Content-Type: application/octet-stream
    in the file i am trying to write.... Can anyone help me fix this problem? I am clueless at this point on what to do..
    sample code below is what i got from trying to work this...
    Thanks in advanced for anyones help..
    <code>  
    const FILE_UPLOAD_URL:String = "http://172.16.1.6:1111/cgi-bin/login.cgi"; 
    private function init():void {fileRef =
    new FileReference();fileRef.addEventListener(Event.SELECT, fileRef_select);
    fileRef.addEventListener(ProgressEvent.PROGRESS, fileRef_progress);
    fileRef.addEventListener(Event.COMPLETE, fileRef_complete);
    private function browseAndUpload():void {fileRef.browse();
    message.text =
    private function fileRef_select(evt:Event):void { 
    try {message.text =
    "size (bytes): " + numberFormatter.format(fileRef.size);fileRef.upload(
    new URLRequest(FILE_UPLOAD_URL) ); 
    trace("going to print file data in a sec... ready?"); 
    trace(fileRef.data); 
    trace(fileRef.name );}
    catch (err:Error) {message.text =
    "ERROR: zero-byte file";}
    private function fileRef_progress(evt:ProgressEvent):void {progressBar.visible =
    true;}
    private function fileRef_complete(evt:Event):void {message.text +=
    " (complete)";progressBar.visible =
    false;}
    </code>

    Here are some code....
    Forms
    <%@ page language="java" session="true" %>
    <html>
    <head>
    <script>
    </script>
    </head>
    <body>
    <form name="myform" method="post" action="fileproc.jsp" enctype="multipart/form-data">
    <input type="file" name="myfile">
    <input type="submit" value="submit">
    </form>
    </body>
    </html>Process
    <%@ page language="java" session="true" import="com.oreilly.servlet.*"%>
    <html>
    <head>
    </head>
    <body>
    <% String s = request.getParameter("myfile"); %>
    <%=s%>
    <br>
    <%
       MultipartRequest multi = new MultipartRequest(request, "C:/multipart/", 10*1024*1024); // 10MB
       Enumeration params = multi.getParameterNames();
       while (params.hasMoreElements()) {
         String name = (String)params.nextElement();
         String value = multi.getParameter(name);
         out.println(name + " = " + value);
       out.println();
       Enumeration e = multi.getFileNames();
       while(e.hasMoreElements()){
           String fname = (String)e.nextElement();
           out.println("<h1>"+fname+"</h1>");
           File fl = multi.getFile(fname);
           FileReader fr = new FileReader(fl);
           BufferedReader buf = new BufferedReader(fr);
           while(buf.ready()){
               out.println(buf.readLine());
           out.println();
           buf.close();
           fl.delete();
    %>
    </body>
    </html>Hope this helps....

  • How do I add a file upload to my form?

    I need to be able to collect multiple files from a web form in order to keep them together.

    Hi DonPhilyaw,
    You can add a attach a file button in your form and you can get all the attachments at one place.
    Thanks,
    Vikrantt Singh

Maybe you are looking for

  • ICloud Control Panel and Windows 8

    I cannot get it to install.....any help?

  • Need some help with the colour profile please. Urgent! Thanks

    Dear all, I need help with the colour profile of my photoshop CS6.  I've taken a photo with my Canon DSLR. When I opened the raw with ACDSee, the colour looks perfectly ok. So I go ahead and open in photoshop. I did nothing to the photo. It still loo

  • IOS 8.02 Safari for iPhone 5 - A Problem Repeatedly Occurred

    I can't open the webpage: "www.BirthdayExpress.com" (and some others) on my iPhone 5 in Safari since the iOS 8 update.  It would load fine earlier before the update, and also loads on Chrome just fine. The error is: A Problem Repeatedly Occurred on:

  • Sales BOM

    Hi All, When we update Sales BOM by replacing an item or quantity the corresponding item open sales quotation and open Sales order don't get updated. Is there a way to update all the open quotation or orders simultaneously when we update the sales BO

  • Install jnlp for all user in 1 PC through web.

    Dear all, Any clue how to install the jnlp under directory like C:\Documents and Settings\All users\Application Data\Sun\Java\Deployment\cache....... rather than C:\Documents and Settings\"User Name"\ Already tried to set the <property name="deployme