What to do about sessions?
Hi, I'm using restlet with google app engine. I need to support session state. If a user logs in, I want to remember that they're still logged in when they switch between pages, so they don't have to keep re-authenticating. I read through the posts here about sessions not being supported by restlet, which I don't full comprehend (I am new to this). I have a login servlet, and am doing something like this: HttpSession session = request.getSession(); if(ProvidedUserParametersAreOK){ session.setAttribute(user, name); then in my other servlets, I'd like to check if the user is still logged-in: HttpSession session = request.getSession(false); if (session.getAttribute(user) != null){ User user=(User)session.getAttribute(user); //user logged in but we don't have access to the session in our ServerResource derived servlets. If a restful application is not supposed to support sessions, where would I keep this session state information then? Just wondering how to implement this really, Thanks -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2590519
RE: Re: What to do about sessions?
Hey Stephen, Ok so I get that sessions shouldn't be supported by rest, totally fine with that. I'm confused about how to use basic auth then instead, if that's the preferred method. If we use basic auth, then we need to send the username and password as plain text, right? This could be fixed by using https. But this also implies that every rest call made must supply username:password in the request, right? In that case, then in order to protect the user, every rest call should be done using https. Is that correct? Thanks -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2590591
Serving GWT app from different urls?
Hi, I'm using GWT and app engine. I setup an Application-derived class to do the url routing, works great. Is it possible though to serve my gwt app at these different urls though? For instance, I will have my landing page: www.mysite.com and user pages: www.mysite.com/johndoe it's not clear to me how I can get Restlet to serve my gwt app when the user enters: www.mysite.com/johndoe ideally both urls serve the same GWT app, but in the second case, I can grab the 'johndoe' part from the url, and iniitialize the app with data for that user. This setup is really common with PHP I think. Can we do the same thing with Restlet? I know GWT allows you to do it using # instead: www.mysite.com#johndoe but this just looks odd to the end user. Thanks -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2493562
A POST request with query parameters?
Hi, I just was shown how to get the parameters of a GET request using the following: Form queryParams = getReference().getQueryAsForm(); String size = queryParams.getFirstValue(size); this works perfectly. I'm constructing a POST on a java client like this: HttpPost httppost = new HttpPost(url); ListNameValuePair nameValuePairs = new ArrayListNameValuePair(2); nameValuePairs.add(new BasicNameValuePair( param1, abc)); nameValuePairs.add(new BasicNameValuePair( param2, 123)); httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); HttpResponse response = httpclient.execute(httppost); in my servlet, I'm trying this: @Post public String acceptRepresentation(String value) { Form form = getRequest().getResourceRef().getQueryAsForm(); } The Form object reports that there are no key/value pairs, it's empty. But the 'value' parameter passed into acceptRepresentation() contains my entire query string like: param1=abcparam2=123 that works fine for me, but wondering if there is a better way to be getting these key/value pairs, as in the original GET example? Thank you -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2460268
RE: Re: A GET with query parameters?
Ok thanks, yeah was missing that you could do that at all, works well now. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2460202
A GET with query parameters?
Hi, I'm using restlet with google app engine, but think this is just a general restlet question. I want to support a GET method where the user can supply some query parameters like: http://mysite.com/farms/size=n so the user can do a GET on the farms list but only return a list of farms that have a size of N. What's the proper way to do this with restlet? I've got this: router.attach(/farms/{size}, Farm.class); public class Farm extends ServerResource { @Get public String represent() { Request request = getRequest(); String params = getRequest().getAttributes().get(size); } } that works, I'll get size=12 etc. Is this the right way to do it, or is there some more structured approach to parameters? If I have like 12 parameters, I have to explode the string etc etc to get the param names and their values and all that fun stuff. No big deal, just want to know if this is the right way to go. Thanks -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2460126