aspose file tools*
The moose likes Other Open Source Projects and the fly likes Servlet image upload problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Servlet image upload problem" Watch "Servlet image upload problem" New topic
Author

Servlet image upload problem

fredrick esedo
Greenhorn

Joined: Mar 04, 2010
Posts: 23
Good day everyone and thanks for help rendered so far.
Please scholars,this my servlet code is displaying an 4 errors as shown below
and i need your help




Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\esedos>cd C:\Tomcat 6.0\webapps\form2\WEB-INF\classes

C:\Tomcat 6.0\webapps\form2\WEB-INF\classes>javac UploadFile.java
UploadFile.java:62: illegal character: \8211
int boundaryLocation = file.indexOf(boundary, pos) û 4;
^
UploadFile.java:73: illegal character: \8211
fileOut.write(dataBytes, startPos, (endPos û startPos));
^
UploadFile.java:73: not a statement
fileOut.write(dataBytes, startPos, (endPos û startPos));
^
UploadFile.java:73: ';' expected
fileOut.write(dataBytes, startPos, (endPos û startPos));
^
4 errors




The servlet code is stated below












Please also check my html code as my database has 2 columns; fname with varchar and image with blob
and i dont know the way i referenced them in my servlet and html is correct.

Thanks and regards

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39548
    
  27
If you look at your post, you can actually see the invalid characters. Those are not minus signs, but some other character that looks like a minus sign:

UploadFile.java:62: illegal character: \8211
int boundaryLocation = file.indexOf(boundary, pos) û 4;

UploadFile.java:73: illegal character: \8211
fileOut.write(dataBytes, startPos, (endPos û startPos));


Ping & DNS - updated with new look and Ping home screen widget
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60057
    
  65

Are you using Word or WordPad to write code?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
fredrick esedo
Greenhorn

Joined: Mar 04, 2010
Posts: 23
Thank you very much Mr.Dittmer and Mr. Bibeault for your wonderful help.
Regarding the code I remove the -sign and add +sign and the error gone.
But the problem now is that when i run the program using URL




it returns an empty page instead "success your file is saved" which infers that the image is not uploaded into the database.

my web.xml is as follow



I have only 2 columns in my table; fname column which has datatype "varchar" and image which has datatype "longblob"
my html file has cloumn name as shown below which corresponds with the 2 column name i have in the database and yet
the image upload is still problematic. Please Sir, help me .Rargards and God bless.



ie name="fname" and name="image"

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18135
    
    8

So your code now compiles, but it doesn't do what you expect.

That may be because you changed the logic; it would have been better to replace the bogus minus signs by real minus signs, instead of plus signs, in my opinion. But anyway there's a good chance your code threw an exception. Have a look on the server and see if it did. There should be logs where stack traces go.
fredrick esedo
Greenhorn

Joined: Mar 04, 2010
Posts: 23
Thank you very muc sir but i am ineffective in solving this problem
fredrick esedo
Greenhorn

Joined: Mar 04, 2010
Posts: 23
Please sir i hav gone through the code and i dont know what to do. Please check if the column name
"fname and image" that i used in my database is incorrect with the code .I guess the problem can equally come from using incorrect columname .Please sir help me check
Thanks and Regards
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39548
    
  27
Paul said:
Have a look on the server and see if it did. There should be logs where stack traces go.

Do you know what log files are, and where to find them on your server?
fredrick esedo
Greenhorn

Joined: Mar 04, 2010
Posts: 23
thank you i have seen it and what the problem is all about
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlet image upload problem
 
Similar Threads
Large File Size Upload Problem
Submitting a text field along with a file?
error in uploading zip file
problem in uploading a file
JSP Page For Uploading a File to Destination Folder