user2532297
user2532297

Reputation: 81

Get screen size in Google App Engine

In a servlet I'm running on GAE, I'm trying to get the screen width in pixels of the device being used so that I can dynamically redirect the user to either the desktop or mobile jsp page. I first tried using the java.awt.Toolkit.getDefaultToolkit().getScreenSize() but receieved the error message: java.awt.Toolkit is not supported by Google App Engine's Java runtime environment. For now, I'm running the screen check in a jsp page using javascript but I'd like to move it to the servlets.

Upvotes: 0

Views: 148

Answers (1)

nanofarad
nanofarad

Reputation: 41281

You can't move it to the servlets. The server is not aware of the user's screen or any details besides user-agent and what Javascript provides. You'll need to use Javascript and pass around the screen size in a cookie or in the requests.

java.awt.Toolkit.getDefaultToolkit().getScreenSize()

being run on GAE is not applicable as we don't care about GAE's screen which is nonexistent anyway.

Upvotes: 1

Related Questions