Two Laptop Bag*
The moose likes Servlets and the fly likes Resolution Detection with JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Resolution Detection with JSP" Watch "Resolution Detection with JSP" New topic
Author

Resolution Detection with JSP

Heitor Bembom
Greenhorn

Joined: Jul 11, 2000
Posts: 10
I am working on a project and I am trying to find out the user's screen resolution using Java and them add it to the JSP session variables.
Is there any way I can detect the screen resolution with Java? Something like the JavaScript's methods: screen.height and screen.width....
Thank You,
Heitor Bembom
Tony Alicea
Desperado
Sheriff

Joined: Jan 30, 2000
Posts: 3222
    
    5
I tried a simple (Servlet) test today and none of the headers coming from the client browser had that information.
I think it's a good question.
And I think that the answer is in the servlet API being augmented to return that property from the browser. It is obvious (via JavaScript) that the browsers are capable of querying the client system to get that info so I would expect the Servlet API to at least in principle be able to get to the same info. Maybe soon?


Tony Alicea
Senior Java Web Application Developer, SCPJ2, SCWCD
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
The problem is not with the servlet API. There is already a mechanism for querying the value of an arbitrary header. The problem is (as Tony points out in his first sentence) that the browser just doesn't send that information to the server.
Sure JavaScript can find it out, but JavaScript is running in the browser. Any server-side system can only know what it has been told over its socket connection from the browser. If the browser doesn't tell the server what it's screen size is, then the server can't pass it to your servlet.
If you really need this information, then you could consider passing it from JavaScript by building a URL such as /servlets/size?x=1024&y=768 or by using an applet which opens a socket connection to your server.


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Heitor Bembom
Greenhorn

Joined: Jul 11, 2000
Posts: 10
Yeah...

I have already done that. I am loading the logon (JSP) page with a conditional that looks for some variables in the query string. If they are not there I call a JavaScript that catches those values and I add them to the URL. After that I reload the page with the new URL.
Thanks for your help,
Heitor Bembom
 
 
subject: Resolution Detection with JSP
 
Similar Threads
Problem in detecting Resolution change
Changing Screen Resolution
Changing screen resolution using java
Dyanmic Screen Resolution in J2ME
screen resolution problem