Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to place image on particular location on webpage? pixels?

 
Vikrama Sanjeeva
Ranch Hand
Posts: 760
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

This could be a very simple :$. Well, I have an image say, a circle in JPEG format which I want to place on a particular location on a webpage. Location will be decided on the basis of the pixels given. Suppose,



Now, above circle should be displayed on the webpage, such that, center of the circle should be on 200,300.

It is assumed that, circle is already existed in form of JPEG image. Just placing is the issue.

Looking forward for the reply.

Bye,
Viki.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure what this has to do with JSP - seems more of an HTML question. Styling the page with CSS would let you do absolute positioning.
 
Vikrama Sanjeeva
Ranch Hand
Posts: 760
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I do not want to use CSS. The displayCircle(200,300) will be called from a servlet and the actual circle on the given co-ordinates will be displayed in browser.

Any help in this regard will be highly appreciated.

Bye,
Viki.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
THAT IS WHAT CSS IS FOR!

You have to use CSS to do the positioning. CSS is for the style of the page. Without that, you are not able to position anything on the page. Look into absolute positioning on any CSS reference with top and left.

Eric
 
Vikrama Sanjeeva
Ranch Hand
Posts: 760
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

That's OK! I have to use CSS. But I want to set the position (location) of Image on browser from (within) Servlet. That is, in servlet it will be decided where the Image (in fact at what cordinates in pixels) will be displayed on the browser?

I guess, I have to use "out.println("<HTML>")" where out is: "PrintWriter out = response.getWriter();" in servlet and have to form the dynamic HTML from the servlet.

My doubt: Can I use CSS from servlet in the same way as HTML is used?

For example, given the following style sheet:
BODY { font-size: 10pt }
H1 { font-size: 120% }

Can I call out.println(" <H1>A heading</H1>"); from withing the servlet?

Bye,
Viki.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Add the CSS directly to the element that you are dynamiclaly adding...

<img style="position:absolute;top:0px;left:300px;" ..../>

Eric
 
Vikrama Sanjeeva
Ranch Hand
Posts: 760
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thanks Eric. That's simply gr88 .

Bye,
Viki.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic