pivot-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Brown <gkbr...@mac.com>
Subject Re: Hello, I'm a new user.
Date Thu, 15 Apr 2010 12:34:29 GMT
Pivot's web query classes are primarily designed to facilitate REST-style interaction with
a server. Since an HTTP POST is commonly used to create a resource on the server, PostQuery
returns a URL representing the location of the created resource. This is the value of the
Location header described in the HTTP spec:

http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.5

POST can also be used to perform an arbitrary action that doesn't result in the creation of
a resource; in this case, the method can return null. For example, to facilitate login in
an application I recently developed, I defined a POST operation that accepted an "Action"
header with a value of "login". I passed the user credentials in the HTTP headers. If the
login succeeds, HTTP 204 is returned; otherwise, HTTP 401 is returned.

Pivot includes a base servlet class to help simplify development of web query REST services.
It is called org.apache.pivot.web.server.QueryServlet and is defined in pivot-web-server-1.x.jar.
If you think you might be interested in using this class, I would suggest that you look at
the forthcoming 1.5 version, since the API has changed a bit since 1.4 and is now slightly
more consistent with the client classes.

If you definitely need to return a value from your POST operation, you might be able to simply
return it in a response header. If that isn't sufficient, you could create a custom Query
subclass that basically looks like GetQuery but uses the POST method instead:

http://svn.apache.org/repos/asf/pivot/trunk/web/src/org/apache/pivot/web/GetQuery.java

Hope this helps.

Greg


On Apr 15, 2010, at 5:25 AM, Jérôme Serré wrote:

> Hello,
> 
> 
> 
> I begin with pivot and i want to accede to the session in the applet.
> 
> I know send a objet from applet to servlet (QueryPost), but I don’t know to
> get the response (an object). I think to use the session.
> 
> 
> 
> APPLET :
> 
> PostQuery postQuery = new PostQuery("192.168.1.5", 8000, "/vsm/Login",
> false);
> 
> postQuery.getParameters().put("login", login.getText());
> 
> postQuery.getParameters().put("motp", motp.getText());
> 
> postQuery.getParameters().put("page", "login");
> 
> postQuery.execute();
> 
> GET THE RESPONSE ???
> 
> 
> 
> SERVLET :
> 
> public void doPost(HttpServletRequest request, HttpServletResponse response)
> throws IOException, ServletException {
> 
> HttpSession session = request.getSession();
> 
>       /login
> 
>       String d = (String)request.getParameter("login");
> 
>       System.out.println("LOGIN: " + d);
> 
>       //password
> 
>       d = (String)request.getParameter("motp");
> 
>       System.out.println("MOT DE PASSE: " + d);
> 
> SEND THE RESPONSE ???      
> 
> 
> 
> Thank you for your help
> 
> __
> 
> Cordialement
> 
> Jérôme Serré
> 
> 
> 
> 


Mime
View raw message