File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Resolution Detection with JSP

 
Heitor Bembom
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Tony Alicea
Desperado
Sheriff
Posts: 3226
5
  • 0
  • Mark post as helpful
  • send pies
  • 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?
 
Frank Carver
Sheriff
Posts: 6920
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic