[play-framework] Getting the browser user-agent (among other things)

2,437 views
Skip to first unread message

david

unread,
May 4, 2010, 9:00:16 AM5/4/10
to play-framework
I want to get the user-browser string, currently I'm using the the
request object provided by play but I don't see a way to get it (after
checking available functions in netbeans)

I'm having a bit of trouble, since I'm inexperienced with Java I don't
know whats the best way to debug (as in getting the arguments used in
a POST and writing them in html or other way) for example I want to
know what kind of input I'm getting.

I started creating a guestbook app to get familiar with both java and
play!, started using module:crud, thing is I'm on windows platform and
when I type "play crud:ov --templates app_path" it doesn't do
anything. Also, is this a good practice? in mysql I have a table with
the following columns (id,comment,guestname,ip,browser, replyTo)

replyTo is where does this comment falls into, so I have multiple
constructs in my model class and I wondered if it was a good practice
<code>
public Comment() {}

public Comment(String comment, String guestname, String ip, String
browser) {
this.comment = comment;
this.guestname = guestname;
this.browser = browser;
this.ip = ip;
}
public Comment(String comment, String guestname, String ip, String
browser, Integer replyTo) {
this.comment = comment;
this.guestname = guestname;
this.browser = browser;
this.replyTo = replyTo;
this.ip = ip;
}
</code>

Another thing is how to manage errors? lets say the field was empty
and I "throw an exception? or just use flash?"

--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To post to this group, send email to play-fr...@googlegroups.com.
To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.

Marcos Silva Pereira

unread,
May 5, 2010, 12:05:55 AM5/5/10
to play-fr...@googlegroups.com
String user_agent = request.headers.get("User-Agent");


Kind Regards,
--
Marcos Silva Pereira
http://marcospereira.wordpress.com
"People who are crazy enough to think they can change the world, are the ones who do."

Ron Gross

unread,
May 31, 2012, 5:04:23 AM5/31/12
to play-fr...@googlegroups.com
FYI, now it's actually        

Http.Header uaHeader = request.headers.get("user-agent");

(Notice the lower case "user-agent")
To post to this group, send email to play-framework@googlegroups.com.
To unsubscribe from this group, send email to play-framework+unsubscribe@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.

--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To post to this group, send email to play-framework@googlegroups.com.
To unsubscribe from this group, send email to play-framework+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages