This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Servlets and the fly likes Http Response Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Http Response" Watch "Http Response" New topic
Author

Http Response

siddharth das
Ranch Hand

Joined: Aug 17, 2007
Posts: 124
hello ,
i want to send a picture from server to client
so that i write

but if i need send image and text,then what i will write.
please suggest me.Thank You.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

You can send binary data or text, not both.
If you describe what you're trying to accomplish, maybe someone here can point you in the right direction.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41626
    
  55
You can only have one content type, text or image. The text (or rather, HTML) can contain an image that once again references the servlet so that it serves an image; but that would be a separate follow-up request.


Ping & DNS - my free Android networking tools app
siddharth das
Ranch Hand

Joined: Aug 17, 2007
Posts: 124
suppose a client sends her name.
The server should display her name with a jpeg photo.
so how can i write
Thank you[ ]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Return an HTML page that contains an <img ../> tag.
The tag should have a 'src' attribute that points to your image servlet.

I have an example app that does this on my site.
http://simple.souther.us
Look for SimpleStream.
Saurabh Patil
Ranch Hand

Joined: Dec 11, 2005
Posts: 45

yes. Ben is right, simply return a html page which contains an image!


All for one and one for all!
 
wood burning stoves
 
subject: Http Response