Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getScreenSize() shows server screen size

Status
Not open for further replies.

Shilohcity

Technical User
Jul 12, 2000
136
GB
Hi there

I am pretty new to JSP pages and was wondering if anybody could help me out with this.

I am using the following code in the hope I can set the value of a framset page for scroll bars on 640 x 480 screens. It is actually returning me the value of the server screen size and not the client screen...This confused me for a very long time :). The same code running as javascript works fine though.

page import="java.awt.*"

// Get toolkit
Toolkit toolkit = Toolkit.getDefaultToolkit();

// Get size
Dimension dimension = toolkit.getScreenSize();

// Print size
System.out.println ("Width: " + dimension.width);
System.out.println ("Height: " + dimension.height);

I am using IE5 and serving JSP through Tomcat 3.3 and IIS.

All help most appreciated.

Justin X-)
"Creativity is the ability to introduce order into the randomness of nature." Eric Hoffer

Visit me at
 
That because JSP is run server side and Javascript is run client side. Thus the JSP code will return the server screen size and Javascript will return the clients screen size.
 
Code running on the server cannot know the screen size of the client that sent the HTTP request unless you use javascript to send that in the request parameters.

You can then use the request parameters to adjust the size of the frames that are sent back from the server to the client.
 
Thanks for the comments. I had figured as far as the server side vs client side but I have some similar code using asp which basically assembles the page based on some javascript vars. I thought maybe in JSP it was possible to skip the javascript section. I see how to do this now though using the request info.

Thanks again
Justin X-) "Creativity is the ability to introduce order into the randomness of nature." Eric Hoffer

Visit me at
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top