URGENT.........File Upload using Servlets and jsp

I am a new servlet programmer.......
iam using tomcat server......
can any one pls help in writing code for file upload using servlets and jsp without using multipart class or any other class like that....
Please URGENT..

Slow down! "Urgent" is from your perspective alone. I, myself, am not troubled or worried in the least.
hi ugniss
thanks for ur reply....sorry i was not
y i was not asked not to use multipart class or any
other class like that...is there any other
possibility to do file uploading from jsp to
servlet...
Just as an aside, a JSP is a Servlet. But even if I move beyond that, the question does not make sense. If you want a "JSP to upload to a Servlet", then simply do so in memory. You are still (likely) within the same scope of a given request. However, if instead you are referring to a JSP that is displayed on a browser, then really you are talking about HTML, which is what the browser will receive. And since you are now talking about a browser, your only real, viable option is a multi-part file upload. So, it is either server or it is browser. And either way, the question leads to very established options, as outlined above.
the main concept is.. in the browser the user selects
a particular file and clicks the button upload..after
clicking upload the jsp should sent the file to the
servlet in streams...there the servlet gets in and
saves in a server location........this is wat i hav
to do...
Okay. So, after reading my previous (redundant) paragraph, we have arrived at the crux of the issue. You have a JSP that will be output as HTML to a client (browser) which you want to upload content to your server (handled by a Servlet). So, you are now stuck again with multi-part. The requirement to not use multi-part is non-sensical. You can overcome it, say, if you write your own applet or standalone Swing client. However, if your users are invoking this functionality from a browser, you are limited by the options that W3C has provided you. Use multi-part.
is there aby possibilty to do this.....can any one
pls help....Take the advice to download and review Jakarta Commons FileUpload. Inform your management that their requirement makes no technical sense. Research on your own. There are dozens of examples (and tutorials) on file upload using multi-part. Embrace it. Live it. Love it.
- Saish

Similar Messages

  • File upload using Servlets and Weblogic

    Hi,
    I need to write a servlet that can upload a .doc file to a folder on the server. Can someone please let me know abot the code i need to write, as i am a novice in servlets.
    Thanks in advance
    buddy0303

    Another, simpler (we think), such package is Jenkov HTTP Multipart File Upload. It's a servlet filter which can work in front of both servlets and JSP's. The servlet filter parses the uploaded file and stores it temporarily on the servers disk. When the servlet or JSP executes afterwards, it can obtain all the information about the file, from the request attributes. There is a decent manual for HTTP Multipart File Upload on the website.
    Just search for "Jenkov HTTP Multipart" on Google and you'll find it. HTTP Multipart is free, open source, Apache Licsense.

  • File Upload using struts and jsp

    Hi,
    Anybody have sample coding for uploading files into the database using struts and jsp.
    Thanking you in advance for providing the sample coding.
    Veena

    Hi Veena,
    In Strutsconfig.xml you have to configure data sources like this
    **************strutsconfig.xml******
    <data-sources>
    <data-source
    type="org.apache.common.dbcp.BasicDataSource">
    <set-property property="driverClassName"
    vlaue="oracle.jdbc.driver.OracleDriver"/>
    <set-property property="url" vlaue="jdbcracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SID =ORCL)))"/>
    <!-- <set-property property="url"
    vlaue="jdbcracle:thin:@127.0.0.1:1521:ORCL"/>-->
    <set-property property="username"
    vlaue="scott"/>
    <set-property property="password"
    vlaue="tiger"/>
    </data-source>
    </data-sources>
    Now here is how to get data source
    public class LookupAction extends Action
    public Double getQuote(String symbol,
    HttpServletRequest request)
    throws Exception
    Double price=null;
    Connection conn=null;
    Statement stmt=null;
    ResultSet rs=null;
    DataSource dataSource=null;
    try
    dataSource = getDataSource(request);
    conn= dataSource.getConnection();
    stmt= conn.createStatement();
    rs= stmt.executeQuery("select * from stocks where" + "symbol='" + symbol +"'");
    if (rs.next())
    =======================
    After you can use the coding what I posted earlier.
    For that you need to create a table with attachment as a CLOB col.
    then with prepared statement I am setting value .
    Plz try your self every thing ok you can get that.
    all the best
    bye
    sudheen

  • File download using servlet and jsp. File Dialog comes twice

    Hi
    I was trying to download a file using servlet. There is a link which calls the servlet. When I click on the link file dialog box comes up. On selecting Open it again shows me the file dialog box. I changed the method from POST to GET and it worked properly.
    My question is why does it work with GET and not with POST. I am aware of the differences between POST and GET but am not able to come to a rational explanation for this behaviour.
    Please if anyone can explain this to me I am going crazy thinking an answer for this.
    Thank you.
    Regards
    Jay

    Hi Jay,
    I also have the same question. Why does it work with GET and not for POST?. If you were able to find the answer please let me know.
    Thank you.
    Regards,
    Aravind

  • How to use servlets and JSP for my homepage?

    servlets and JSP are server-side program. If my homepage is on some web-hosting websites, can I upload the servlets and JSP to run it? if possible, where can I find such a web-hosting place?
    sraiper

    Not many hosts offer JSP or Servlet support (and some do but then stop and never give you a refund, grrrrrrr!!!!).
    Also, ones that do support it can often be more expensive. There are some free ones but all the one's I've come across have problems that made them unsuitable for my needs.
    Here is a list of hosts that support Java:
    http://www.thejspbook.com/resources/category.jsp?id=1005&name=JSP+web+hosting
    I can't comment on any from that list, however I use http://www.positive-internet.com they are a bit pricey but they have excellent support and are always happy to help with any Tomcat (the JSP/Servlet server they use)configuration issues or needs that you may have.

  • Download local file using Servlet and JSP

    Hello,
    I will like to use a browser to download file on local system using serlvet and Jsp technology. Does anyone have any idea how to do it?
    Any comment will be appreciate.
    Thanks

    Well you can just put the file in a folder that is accessible to the web server. Then have a link point to that file. That will cause the web browser to download the file.
    hattan

  • User Authentication using Servlet and JSp

    Hi,
    I am developing a web app where i need to implement user Authentication to allow members to view and upload files on a certain directory say /data
    For this i am using a servlet as a controller which then forwads request to other jsps/servlets based on user response. I tried using servlet mapping in web.xml so that all browser requests would be directed to controller servlet and would branch from there on. However the problem all RequestDispatcher.forward() requests redirected to the servlet putting it in a loop.
    Is there another way to achieve this. (Apart from using form-based Basic Authentication).
    I am using Resin 1.2.8 servlet/jsp container.
    Any response as soon as possible would be appreciated.
    Thanks,
    Kushagra

    RequestDispatcher.forward() cause the HTTP request to be sent through the request processing flow as if the original request for the resource being forwarded to.
    It seems the servlet mapping you are talking about in web.xml should be made more specific. i.e. the mapping should be such that only your so called controller servlet will match up.
    You might want to specify the mapping for the controller servlet to be noticeably/effectively different from the mapping for other servlets and JSPs.

  • When to use servlets and jsp in an application like  shoping cart?

    Hi All
    I m going to design and implement a web application using servelts and jsp. I am still at its requirements analyze stage.
    The application is almost likely a shopping cart. So if any of you have the deep knowledge about this domain with servlets and jsp please help me for a good design. What I realy need to know is that
    1. what are the core requirements for a shoping cart ?
    2. use cases ?
    3. best way to follow mvc with servlets and jsp for it?
    you can answer to this at the abstract level. no need to go in detail.
    if you have any documents like design and use cases mail me to [email protected]
    your cooperation is highly appreciated in this regards.

    Look into this kid
    http://www.apl.jhu.edu/~hall/java/Servlet-Tutorial/Servlet-Tutorial-Session-Tracking.htm

  • File uploads using servlets to oracle8i database

    Hi,
    Help please, How I can a File Upload using BLOB's into the oracle database, any sugestions...
    Thanks
    Moacyr
    [email protected]

    Try the jason hunter book Java Servlet Programming for a very good description or the web site hosted by o'reilly
    www.servlets.com
    Has a very neat java class for decoding multipart mime encoded files (the upload stream from the browser). Seems to accomodate most of the differing browsers intretation of the standard.
    Note to Oracle: This should really be handled by the servlet engine as an Oracle extension. Where the servlet engine strips the mime encoding out before the servlet is called placing the decoded file in an associated extension call. ie: cast the request to an Oracle request object which has file uploaded method.

  • File upload using uiXML and Struts

    Hi,
    I am using Struts as my controller component with uiXML for the UI. I need to add file upload functionality to one of my pages. After a bit of trial-and-error, I figured out that the following code in my uiXML sets me in the right direction -
    <struts:form name="myForm" method="post" beanName="myFormBean" usesUpload="true" destination="/try/SaveTry.do">
    When the "destination" attribute is not specified, the Struts action does not get the file. However, with the changes above, the uploaded file now reaches my Struts action, which does the necessary processing and the Struts controller forwards the control to the next page according to its logic.
    However, at this point, I see the following on the browser -
    java.io.EOFException
    at oracle.cabo.share.util.MultipartFormHandler._readLine(MultipartFormHandler.java:207)
         at oracle.cabo.share.util.MultipartFormHandler._readLine(MultipartFormHandler.java:192)
         at oracle.cabo.share.util.MultipartFormHandler._skipBoundary(MultipartFormHandler.java:176)
         at oracle.cabo.share.util.MultipartFormHandler.<init>(MultipartFormHandler.java:82)
         at oracle.cabo.share.util.MultipartFormHandler.<init>(MultipartFormHandler.java:59)
         at oracle.cabo.servlet.io.BaseFileUploadManager._doMultipartRequest(BaseFileUploadManager.java:93)
         at oracle.cabo.servlet.io.BaseFileUploadManager.decodeMultipartRequest(BaseFileUploadManager.java:57)
         at oracle.cabo.servlet.AbstractPageBroker.decodeMultipartRequest(AbstractPageBroker.java:534)
         at oracle.cabo.servlet.PageBrokerHandler.handleRequest(PageBrokerHandler.java:103)
         at oracle.cabo.servlet.UIXServlet.doGet(UIXServlet.java:170)
         at oracle.cabo.servlet.UIXServlet.doPost(UIXServlet.java:139)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.0)].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:810)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.0)].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:322)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.0)].server.http.ServletRequestDispatcher.forward(ServletRequestDispatcher.java:220)
         at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1063)
         at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:386)
         at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:229)
         at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
         at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.0)].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:810)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.0)].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:322)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.0)].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:790)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.0)].server.http.HttpRequestHandler.run(HttpRequestHandler.java:270)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.0)].server.http.HttpRequestHandler.run(HttpRequestHandler.java:112)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.0)].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
         at java.lang.Thread.run(Thread.java:534)
    I tried to specify my own file upload manager (which does nothing) and also tried to subclass the UIXPageBroker to return false in shouldHandleUploadFile() and null in decodeMultipartRequest(), all to no avail.
    Could somebody please let me know if I am missing something? Why is the AbstractPageBroker still kicking in after my file upload has been processed?
    Thanks in advance,
    Smarto

    Thanks Kennethkawamoto2, now i knew the reason, but still i am getting error for crossdomain.xml , when moving flash on production.
    I am putting it as below,
    Security.loadPolicyFile('xmlsocket://ipaddress:80/crossdomain.xml');
    can anybody help?
    much appreciated,
    Meghana

  • File upload using applet and opera

    Hello All
    I am uploading file using applet it is working file in the IE and Mozilla firefox but it doesn't work in the opera , The client is sending request but server doesn't respond it , why it should be happening with opera only . i am using jre1.6 , applet is loading successfully . But while uploading file response from server is not occur.
    please post u r comments.

    On the server side, you'll probably want to grab a 3rd party library for handling the multipart request.
    This one is very popular and has sample code in its documentation that should get you going pretty quickly.
    http://jakarta.apache.org/commons/fileupload
    For the client side, this question would probably do better in an applet forum.
    One obstacle you'll need to deal with is the applet sandbox. By default, Applets have no access to the client machine's file system. You'll either need a signed applet that will prompt the user for permissions to access files or you'll need your clients to install a security policy that allows your applets to do this.
    Again, these details will be better worked out in an applet forum.
    -Ben

  • File upload using Struts and hidden field

    Hi,
    I have seen many examples to upload file using <html:file> tag. But my request is how to upload file using hidden form field and ActionServlet.
    I want to upload image without using Browse button options, through hidden field i will set the image file path and will upload to server using ActionForm.
    Please help me friends to solve this new issue,
    regards,'
    dhaya.

    That's not possible.
    If it was, it would be a huge security hole. What about mailicious websites with hidden field which points to "c:/my documents/passwords.txt" and automatically submits the form using Javascript?
    Consider a signed applet instead. If it is unsigned then you'll get a security popup "Do you trust this software?" anyway.

  • Creating FOrums with Servlet and JSP

    Hi everyone,
    Is there a good resource that explains how to build a forum using servlets and JSP technology?
    Regards,
    Basil Mahdi

    please let me know here if you find any useful resources...I am in the process of writing my own searchable threaded forum for my company with JSP's/servlets. It's a very slow process at the moment though...if I ever finish it, I'll gladly share it.

  • Servlet and JSP in OAS

    I'm developing web application with OAS
    4.0.8.1 and JDeveloper 3.0 and I want to call
    JSP from servlet using "RequestDispatcher".
    I downloaded JSP for OAS from www.olab.com.
    In the Release note, there is a description
    about RequestDispatcher, but I cannot
    understand about details.
    In what configuration can I use servlet and
    JSP together with RequestDispatcher. Anyone
    scceeded about that?
    null

    wan (guest) wrote:
    : Hi everyone,
    : I am using OAS 4.0.8 on Solaris 2.6. After viewing servlet
    : and JSP samples, I am kind of confuse whether OAS supports the
    : following options
    : 1. JSP
    : 2. servlet chaining
    : 3. running JDeveloper DB Servlet wizard
    : (oracle.jdeveloper.servlet.*) and Java Business Objects
    : (oracle.jbo.rt.cs)
    : Thank you for your time.
    I found a white paper 408newfead.pdf, that says under "Future
    Directions" that it will add jsp support. I read somewhere (I
    can't remember where exactly :( ) that said 4.0.8.1 would
    support
    JSPs. I don't know if this release is out yet.
    I wish Oracle would get with the times and put out a product that
    is consistent with the technology they are touting as the
    future.
    Having us download Suns server to run servlets and JSP is
    ridiculous for the worlds second largest software company!
    null

  • JDBC installation for servlets and jsp

    Hello All,
    I am trying to use JDBC for my web application. i have a book but not very detailed and cannot find a good search on google.
    they have said that the ODBC-JDBC bridge driver comes with jdk1.2 or forward. and ask me to set up an ODBC data source. so i went in control panel/systems tab and then try to add SQL and then when click finish it asks me how to connect to sql server, i entered my usename and password but says connection failed.
    This is my worst nightmare. please help so i can start building web application using servlets and jsp.

    Let me tell you right now, you have BORING nightmares.

Maybe you are looking for

  • Is there any resources about how to write ADT?

    I know the adt is actrually abstract data type. but in our exam there are question about how to transfer java coding to adt I search internet there is books about adt in usa. but not accseable in malaysia there seemed no norm or free introduction sit

  • How to read doc/docx/pdf/jpg files in objective-c?

    Hi am new to  objective-c,here want to read the files from the directory i know how to read the text file but what i need is to read the doc/docx/pdf/jpg files to read,i don't know how to read these files in objective-c if anyone knows about this ple

  • Guide on cin

    please guide me how sholud i  learn cin what sholud be the approch to learn this and if can anyone share his expreince how understood this topic that will be very much valuable to me thanx

  • Forms - Database field validation

    Hi, I am having an end date column in my form. It will move to the next record when the user presses down arrow key. Here i want to perform date overlap validation. But in query mode the form simply moved to the next record(i am not saving the form).

  • Why is my iphone's screen blank although every other component is working fine?

    So i was sitting watching a stream on my iphone when it spontaneously started flickering the volume control, i hit the menu button but i still heard the sound from the stream even though my menu was up, i decided to shut off the phone and turn it bac