Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

In need of help urgently with servlets  RSS feed

 
Aine Moloney
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm in my final year of computer science and i'm doing a project on uploading images from a camera phone to an online website and i am getting very confused with servlets. I have set the class path correctly but my problem is that i am confused with HTTP connection. I am sending over an image as a series of btyes. I want the servlet to take the image and upload to the website but i get confused as to what to do with response and request. If anyone could shed some light on the problem i would be dleighted.
Thanks
aine
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you going through a browser or are you writing your own client?
 
Eugene Lucash
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To get byte[] or Stream of image from request you need some fileupload parser
tool like apache commons

There are documentantions, downloads etc at
http://jakarta.apache.org/commons/fileupload/

user guide
http://jakarta.apache.org/commons/fileupload/using.html
 
Aine Moloney
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Thanks for your reply.
My client is the phone, which is a J2ME application. Here is a bit of my code for my servlet. I know its not much but i'm not really sure where to go next. I don't understand upload file parser.
Thanks a million
�ine

public void doPost(HttpServletRequest req, HttpServletResponse res)
throws IOException, ServletException
{
//Get input stream and read data
ServletInputStream in request.getInputStream();
DataInputStream din = new DataInputStream(in);
byte[] image = din.readBtye();

}
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You've got two issues to deal with:

First, get the upload servlet written.
There is a great library at:
http://jakarta.apache.org/commons/fileupload.
Get it to the point where you can upload from a browser.

Then, you're going to have to figure out how to send a multipart request from J2ME. You probably won't get much good advice on that subject here unless someone here just happens to have some j2me experience.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!