• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

display image and text both on jsp page

 
Lalit Chattar
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64178
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
amrish sharma
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 806
Java MySQL Database Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Mark E Hansen
Ranch Hand
Posts: 650
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64178
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No frames or iframes are necessary. Sheesh. Just use the image tag like it's supposed to be used.
 
chaitanya karthikk
Ranch Hand
Posts: 806
Java MySQL Database Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 650
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 806
Java MySQL Database Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Mark.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic