Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Image retrieval using the url

 
kulli putty
Greenhorn
Posts: 7
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a database with images and I need to access the images in my project and display them in jsp page.
Newbee here i have no idea about getting image and displaying it in jsp page.
Everyone suggested going with creating a servlet and getting the image file.
Can anyone help me with this???
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13074
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Important point:

You don't "display in a jsp page" - you use JSP to write an HTML page that has an <IMG tag that provides the information needed for a servlet to retrieve and send the binary image data. <br /> <br /> GETing the image data is a separate request/response cycle just like GETing every other resource that makes up an HTML page. <br /> <br /> Bill <br /> <br /> >
 
Syed Ali
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you need image servlet to display the images in the jsp , the following line you need in the jsp to get image from the image servlet



image is the image servlet , you also need an entry in the web.xml for image servlet
 
Syed Ali
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you need image servlet to display the images in the jsp , the following line you need in the jsp to get image from the image servlet

<!-- <img src="image?id=${Model.Member.id_member}&domain=Member" height="100" /> -->

image is the image servlet , you also need an entry in the web.xml for image servlet
 
kulli putty
Greenhorn
Posts: 7
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

Thank you for your response.William Brogden & syed ali.
But i dont know how to write a servlet for fetching the image and displaying in the screen.
In my jsp page the number of images depend on certain conditions so the number of images fetched is unknown each time.
I have js for retriving the url location and number of images i need to fetch from the db.
How do i wade further....with the location of image.

Please help me.....
 
kulli putty
Greenhorn
Posts: 7
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



This way i havin a radio button for each image but i dont know how to get the image.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65223
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The src URL of the tag should be the URL of a servlet that serves the image data as the response. Be sure that the servlet sets the appropriate response headers.
 
kulli putty
Greenhorn
Posts: 7
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Bear Bibeault

thank you for replying.

Based on your answer I went through servlet mapping.And I got better understanding of servlets.

But can you help me in how to invoke the servlet from js file where i want to fetch the image.

You said the src should be URL tag of a servlet
I did not understand how should the url be. Any examples or link which i can refer will be helpful in better understanding.

Thank you for taking time to help me .
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65223
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
WHat is the mapping that invokes the servlet? Hope did you map it in the deployment descriptor?

Whatever that is is what you'll use for the image tag src value. This has absolutely nothing at all to do with JSP.
 
kulli putty
Greenhorn
Posts: 7
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for sparing your time I got help else where.
And yes i had done the mapping.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65223
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you have posted this elsewhere? Please read BeForthrightWhenCrossPostingToOtherSites
 
kulli putty
Greenhorn
Posts: 7
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Im sorry bear but i have to correct you there are tutorials through which we can learn and gain knowledge if anyone can help with solutions for a particular problem is the reason they post question in forum.
I serched understood and tried implementing. ("And i never asked for ready made code all i asked is guiding a horse to water drinking it is left to me." - You can ignore this if it hurts your ego )
FYI = For your information
i haven't done "CrossPosting" i just learned Java Servlets better through free tutorials.
From my question itself you should have understood that i had little knowledge about servlets ,
You tried to help me I appreciate it.Thanks for it
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic