• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

Upload and Download files just like attachments in JSP

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,
I am using JSP as a front-end view purpose,
From this page I have to push the data to one of the Action Request System form (AR System 6.3). I am using ARS JAVA API.
As per requirement I have to upload one file from user on JSP and have to push it to this back-end form.
I tried JavaZoom�s javazoom.upload class but its giving me a error and I couldn�t fine this class file anywhere. So this code didn�t work finally.
I need a urgent solution friends.
Please respond with some positive solutions.
Thank you,
Kaushal.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We have a file upload entry in our faq.
See:
http://faq.javaranch.com/search?FileUpload
 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hai Ben,
i am using common file upload by jakarta to yupload file from client side to server i am having error while doing so....Can anyone solve the problem
Error :
org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 7 in the jsp file: /ProcessFileUpload.jsp
Generated servlet error:
ServletFileUpload cannot be resolved to a type

An error occurred at line: 7 in the jsp file: /ProcessFileUpload.jsp
Generated servlet error:
ServletFileUpload cannot be resolved to a type

An error occurred at line: 7 in the jsp file: /ProcessFileUpload.jsp
Generated servlet error:
FileItemIterator cannot be resolved to a type

An error occurred at line: 7 in the jsp file: /ProcessFileUpload.jsp
Generated servlet error:
FileItemStream cannot be resolved to a type

An error occurred at line: 7 in the jsp file: /ProcessFileUpload.jsp
Generated servlet error:
InputStream cannot be resolved to a type

An error occurred at line: 7 in the jsp file: /ProcessFileUpload.jsp
Generated servlet error:
StreamUtil cannot be resolved


org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:512)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 7 in the jsp file: /ProcessFileUpload.jsp
Generated servlet error:
ServletFileUpload cannot be resolved to a type

An error occurred at line: 7 in the jsp file: /ProcessFileUpload.jsp
Generated servlet error:
ServletFileUpload cannot be resolved to a type

An error occurred at line: 7 in the jsp file: /ProcessFileUpload.jsp
Generated servlet error:
FileItemIterator cannot be resolved to a type

An error occurred at line: 7 in the jsp file: /ProcessFileUpload.jsp
Generated servlet error:
FileItemStream cannot be resolved to a type

An error occurred at line: 7 in the jsp file: /ProcessFileUpload.jsp
Generated servlet error:
InputStream cannot be resolved to a type

An error occurred at line: 7 in the jsp file: /ProcessFileUpload.jsp
Generated servlet error:
StreamUtil cannot be resolved


org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:414)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:297)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:305)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

My HTML:


[BPSouther: Added UBB Code tags]
[ November 28, 2006: Message edited by: Ben Souther ]
 
Rancher
Posts: 43024
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ServletFileUpload is in package org.apache.commons.fileupload.servlet, which is not imported (org.apache.commons.fileupload is imported twice).

The other missing classes are not part of Commons FileUpload API, AFAICT, and need to be imported as well.

The import statement is also missing a comma at "java.util.Iteratorjava.io.*".

My advice would be to handle file uploads in a servlet, not a JSP. It will be much easier to handle the upload logic and error cases, and then dispatch to one or more JSP pages depending on the outcome.
[ November 27, 2006: Message edited by: Ulf Dittmer ]
 
Kaushal Pandya
Greenhorn
Posts: 11
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try with these code;


[BPSouther: Added UBB CODE tags]
[ November 28, 2006: Message edited by: Ben Souther ]
 
jothish chokkalingam
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hai error message for the above code:
HTTP Status 404 - d:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\ROOT\uploaded\new.xml (The system cannot find the path specified)
 
jothish chokkalingam
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it is working fine ppl
i have created a folder to put the file
 
jothish chokkalingam
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One more thing pandya
Can i upload zip file using the above code.....
Any ideas and suggestions please provide me.....
 
Kaushal Pandya
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey jothish,
as far as i tested it... it will work for any kind of file.
.doc, .xls, .zip. etc...
if you have any problem do contact me regarding it.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Kaushal Pandya,

Javaranch tip:

If you are going to post more than a line or two of your code, wrap that
code in a set of UBB Code tags.
Doing so will help to preserve your code's indenting, making it easier to read.
If it is easier to read, more people will actaully read it and you will
stand a better chance of getting help with your question.
See UseCodeTags for more
help with UBB code tags.
 
Kaushal Pandya
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ben,
will keep this in mind.
thank you once again.
 
jothish chokkalingam
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ppl,
One more thing downloading a csv file from server i am facing a problem...
My pice of code to throw output to browser
Is this the way to do this....?

For the above code i am getting the output stream from browser not the expected one it is throwing with error message stating couldn't read the file
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
where should we create the folder "uploaded"?
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic