aspose file tools*
The moose likes JSP and the fly likes Store Images to database through Jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSP
Reply locked New topic
Author

Store Images to database through Jsp

sravani
Greenhorn

Joined: Dec 06, 2008
Posts: 4
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
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60082
    
  65

"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 ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Store Images to database through Jsp
 
Similar Threads
FileUpload - Form Fields shows Null value
upload file question
Using commons-fileupload-1.2.1.jar to upload file to MySQL
file uploading to db using servlet
Upload Image to database through Servlet