• 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
  • 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

Servlet image upload problem

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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));

 
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:
  • Quote
  • Report post to moderator
Are you using Word or WordPad to write code?
 
fredrick esedo
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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"

 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very muc sir but i am ineffective in solving this problem
 
fredrick esedo
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you i have seen it and what the problem is all about
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic