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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Store Images to database through Jsp

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
hi ,


I used the below code to upload the pictures to database through jsp code. It works fine when i browse the images through temp folder of my working directory. In that code i got a two problems as

upload.jsp



1. I can browse the images from only temp folder of my working directory and i upload the images from other folder it shows error messages as "file not found"

2. When i use the html code like that



It works fine. And i added the another filed to form as image name it didn't work. And shows errors

like that



I used like that i got the error as


org.apache.jasper.JasperException: Exception in JSP: /upload4.jsp:37

34: while (iter.hasNext()) {
35: count++;
36: FileItem item = (FileItem) iter.next();
37: File cfile = new File(item.getName());
38: File tosave = new File(getServletContext().getRealPath("/temp/"), cfile.getName());
39: //item.write(tosave);
40: // String file_name = item.getName();


Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handle JspException(JspServletWrapper.java:504)
org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:393)
org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet .java:802)

root cause

java.lang.NullPointerException
java.io.File.<init>(Unknown Source)
org.apache.jsp.upload4_jsp._jspService(upload4_jsp .java:99)
org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:332)
org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet .java:802)


Please tell that solution.How can i modified my code to resolve that 2 problems
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
"sravani", having ignored multiple warnings to change your display name to comply with JavaRanch requirements, your account has been closed. Should you wish for your account to be re-instated, you must contact me via email.

bear
JavaRanch Sheriff
[ December 11, 2008: Message edited by: Bear Bibeault ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic