• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Resolution Detection with JSP

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Desperado
Posts: 3226
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Heitor Bembom
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
reply
    Bookmark Topic Watch Topic
  • New Topic