aspose file tools*
The moose likes JSP and the fly likes display image and text both on jsp page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "display image and text both on jsp page" Watch "display image and text both on jsp page" New topic
Author

display image and text both on jsp page

Lalit Chattar
Greenhorn

Joined: Oct 22, 2009
Posts: 11
hi i want to display employ profile with image. my code execute correct but display only image which is retrieve from database. How i can display text and image both together on jsp page as profile .
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61434
    
  67

A JSP creates an HTML page to send to the client.

So the real question is: how does one show both text and images on an HTML page.

And I bet you already know the answer.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I'm not sure I understand the question, but without any JSP code to look at it's impossible to help.

Moving to (more) appropriate forum; it may get moved again.
Lalit Chattar
Greenhorn

Joined: Oct 22, 2009
Posts: 11
Bear Bibeault wrote:A JSP creates an HTML page to send to the client.

So the real question is: how does one show both text and images on an HTML page.

And I bet you already know the answer.



Thank you sir

but my image is retrieved from database as a binary stream and other information also from database.
and i want to show both on page.

for image i use response.getOutputStream.write(); function but it show only image.
i want display both binary stream as image and text..

Thank you
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42289
    
  64
The "other information" would be part of the JSP/HTML page. Images are added to HTML pages via <img> tags, they're not part of the page itself. So, it's easy to display both text and images on the same page, but it's impossible to have both be part of the same "stream"; there'll be separate requests for the images.


Ping & DNS - my free Android networking tools app
amrish sharma
Greenhorn

Joined: Sep 24, 2009
Posts: 20
actullay you need to get image from database using servlet with params
for exampple
fetchimage is a servlet to get a desired image send it with parametre
ex:fetchimage?name=amrishwa and specify
chaitanya karthikk
Ranch Hand

Joined: Sep 15, 2009
Posts: 806

Hi Lalit, you cannot get two different content types in one response, my suggestion is to use inline frames and get two different responses, otherwise you have to store the image in your tomcat installation directory under your application, then you can access the image using <img> tag.

I know these two alternatives only, if there is another alternative please tell me so that I can learn more.

Have a nice day.


Love all, trust a few, do wrong to none.
Mark E Hansen
Ranch Hand

Joined: Apr 01, 2009
Posts: 645
anusha chaitanya wrote:Hi Lalit, you cannot get two different content types in one response, my suggestion is to use inline frames and get two different responses, otherwise you have to store the image in your tomcat installation directory under your application, then you can access the image using <img> tag.

I know these two alternatives only, if there is another alternative please tell me so that I can learn more.

Have a nice day.

How about using an Image servlet to serve the image, and just embedding the URL to the servlet in an <img> tag in the generated HTML as others have said?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61434
    
  67

No frames or iframes are necessary. Sheesh. Just use the image tag like it's supposed to be used.
chaitanya karthikk
Ranch Hand

Joined: Sep 15, 2009
Posts: 806

Mark E Hansen wrote:
How about using an Image servlet to serve the image, and just embedding the URL to the servlet in an <img> tag in the generated HTML as others have said?


Hi Hansen, can you explain it clearly, I can learn a new technique, just explain the method.

Thank you in advance.
Mark E Hansen
Ranch Hand

Joined: Apr 01, 2009
Posts: 645
Just look for how to do two things:

1. How to use an <img ...> tag in an HTML page;

2. How to create an image servlet. Just do a search for Image Servlet, and you should find several examples.

The idea is that your JSP page will generate the <img> tag, where the URL will invoke your image servlet, which will serve your image.

Good luck.
chaitanya karthikk
Ranch Hand

Joined: Sep 15, 2009
Posts: 806

Thanks a lot Mark.
 
 
subject: display image and text both on jsp page