• Post Reply Bookmark Topic Watch Topic
  • New Topic

Image did not display from databse in browser through jsp tags.  RSS feed

 
sarojni agrwal
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is my jsp code,



how can I see images in browser...
 
Tim Moores
Saloon Keeper
Posts: 3832
80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Post the HTML it generates.

The last c:out seems to be missing some double quotes.
 
sarojni agrwal
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no HTML here, because, the images stored in database through servlet and then print the images from database through jsp, I have included double quotes here , but can not understand , should I use img tag or not or how can print images in browser from database?
 
Tim Moores
Saloon Keeper
Posts: 3832
80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The img tag is the way to display images in a web page.

What do you mean, there's no HTML? The whole point of the JSP is to generate an HTML page, isn't it?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66152
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is ${ty.Image} the URL of the image? Because that's what HTML expects there.

Also your naming is poor: what's "ty"? Don;t abbreviate. And property names should begin with a lowercase letter.

SO again, what is the HTML generated here? Do a View Source at the browser.
 
sarojni agrwal
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry this is my jsp page in which I created input texts:

 
sarojni agrwal
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And Bear ${ty.Image} is not URL, This is my Proper code, I used Jsp tags(sql jsp tags) in jsp:

 
Tim Moores
Saloon Keeper
Posts: 3832
80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Again : post the HTML that gets generated. That's what we need to see in order to guess at what's going wrong.
 
sarojni agrwal
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Html





and this is view source










and this is the jsp sql tags that I have used.



 
Paul Clapham
Sheriff
Posts: 22374
42
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


That's where you were expecting an image to show up, right? But what you have there instead is what you get when Java executes toString() on an array of bytes. So presumably ${ty.Image} is an array of bytes.

You should stop writing JSP for a while and start writing some HTML, to get an idea of what your JSP should be doing. Step 1: How do you cause an image to appear using HTML? (Hint: Not by embedding a byte array in the HTML.) If you don't know that, then take a minute to find out.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66152
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, is:the data you are wanting to display?

I am assuming not.

It looks as if your understanding of how to use the EL is fundamentally broken. Let's look at"${ty.Design_name}".

Firstly, what is "ty"? It's a mystery! Use better names -- don't needlessly abbreviate.

Secondly, "Design_name" doesn't follow any bean standard. What property in the class represented by "ty" are you trying to display? What is the name of the getter that defines it?

It should likely be getDesignName() and the property name would be designName.

Following conventions for naming isn't optional. It's mandatory for things to work correctly.
 
sarojni agrwal
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is my code , and you will understand ,what "ty" is :




I got everything except Images.....if "ty" was the issue , then why design name and all displayed in browser? I know Naming convention may be the issue somewhere, but here all things displayed in browser except Images.
Screenshot_18.png
[Thumbnail for Screenshot_18.png]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66152
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I still had no idea that "ty" is and as you don't seem to care tell me, nor take my advice to use better names, I guess I'n not going to be needed here.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!