Jump to content

image link problem

- - - - -

  • Please log in to reply
1 reply to this topic

#1
mutago

mutago

    Programmer

  • Members
  • PipPipPipPip
  • 102 posts
Good day everyone ,
i used this code to display image from database i jsp


<img src="image1.jsp?imgid=<%=rs.getInt(1)%>">



how do i use it in servlet as i have move my image1.jsp to servlet.
i tried using this but it errored

img src=image1?imgid=rs.getObject(1).toString();

The servlet image is working. the problem is from the link
thanks

#2
aniruddhp

aniruddhp

    Newbie

  • Members
  • Pip
  • 3 posts
Hi,

There can be the following reasons for your problem:

1) The servlet might need a context to be accessible. For example:

<img src=/<context_path>/image1?imgid=rs.getObject(1).toString()>

Where context_path = Name of the web application context, like :http://localhost:8080/myAppName/index.jsp

2) The other reason why are you doing "rs.getObject(1).toString()" instead of "rs.getInt(1)" in case of servlet?

Thanks,
Aniruddh




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users