Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

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

 
Ranch Hand
Posts: 765
  • 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.
 
Rancher
Posts: 43016
76
  • 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: 765
  • 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.
 
author
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: 765
  • 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
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: 765
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thanks Eric. That's simply gr88 .

Bye,
Viki.
 
Don't destroy the earth! That's where I keep all my stuff! Including this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic