DisplayMode is part of the java.awt package, not the servlet/JSP packages.
You can find out the screen size through JavaScript.  I don't believe the
browser sends the dimensions of itself to the server which is the only way
you could do something like this.

What you could do is in the user's login screen for the session, have
JavaScript discover the monitor sizing, then submit to the server to save
for any additional screens.  You can also use JavaScript to output HTML.  I
use this rarely due to the difficulty in maintaining multiple HTML renderers
(JS and JSP then.)

Steven


----- Original Message -----
From: "Christopher Doyle" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, September 09, 2002 12:13 PM
Subject: Getting screen height and width


> I'm interested in using JSP to get the screen dimensions (not the window
> dimensions) in order to size a graphic on my page. If the screen size is
> greater than 800x600, I want the graphic to be larger. Here's the script I
> was trying to use, but I keep getting errors that I can't make static
> reference to method blah... I tried using the DisplayMode.getWidth()
method,
> but that requires me to create an object of type DisplayMode from which I
> can then get its width. But I'm interested in getting the width of the
> current user's screen, not one I might create in my program. I've also
tried
> the Window.getWidth() with similar results.
>
> Can I do this in JSP?
>
> code:
>
>  String spacer = null;
>  DisplayMode displayMode = new DisplayMode(800,600,24,72); //I don't want
to
> create this
>
>  if (displayMode.getWidth() > 800) {
>  spacer = ("<img src=images/0.gif width=120>");
>  } else {
>  spacer = ("<img src=images/0.gif width=40>");
>  }
>
> Thanks for any help,
>
> Chris
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://archives.java.sun.com/jsp-interest.html
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.jsp
>  http://www.jguru.com/faq/index.jsp
>  http://www.jspinsider.com
>

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

Reply via email to