java ee - How can I display image in JSP? -
i trying display user avatar stored in db on user personal page (jsp) here do
1- have servlet processing login request , produce user bean object. (user avatar byte array ,it may appear multiple times on different pages , locations that's why prefer session attribute rather read them each time db)
2- user bean stored in session attribute.
3- want have jsp or servlet display byte array avatar image anytime.
4- whish servlet reusable other icon images, that's why think can not rely on session attributes pass byte array? (i not quite sure this)
so there design achieve want ? or should use session attributes pass data around?
thanks
how can display image in jsp?
using html <img>
element.
is there design achieve want?
you create standalone servlet that. it's 2 or 3 lines of code in doget()
method. true, servlet not reuseable streaming images straight db, create one. isn't major problem imho.
or should use session attributes pass data around?
only if represents sessionwide data , you've based on performance measurements confirmed keeping user's avatar in session faster streaming db everytime. keep in mind data in session scope accumulates server's memory, make sure images doesn't exceed file size.
Comments
Post a Comment