|
From: Bill B. <bb...@re...> - 2008-08-15 02:05:33
|
I've implemented a simple test injecting HttpServletRequest using
Resteasy Beta 5. I can't reproduce your problem and it works fine for
me so I don't know what to tell you. Are you using Beta 5?
FYI A better way to do this would be:
@ConsumeMime("application/x-www-form-urlencoded")
public String submitForm(MultivaluedMap<String, String> form) {
...
}
You don't need the @ConsumeMime unless your resource can have different
data formats posted to it other than form.
Pranav Parikh wrote:
> Hi,
>
> I'm a beginner in REST.I dont know if this is a right place to post this
> message but I could not find any other place so posting it here.
>
> I'm implementing RESTful Web services for my application. I'm facing a
> few problems when submitting the HTML form using the HTTP POST method.
> I'm not able to retrieve the form parameters I submit using the POST
> method. The "request" object is always null.
>
> My servlet code is as follows
>
> import javax.servlet.http.HttpServletRequest;
> import javax.ws.rs.POST;
> import javax.ws.rs.Path;
> import javax.ws.rs.ProduceMime;
> import javax.ws.rs.core.Context;
>
> @POST
> @Path("/submitform")
> @ProduceMime("text/plain")
> public String submitForm(@Context HttpServletRequest request){
>
> logger.info <http://logger.info>("In submitform"+request);
>
> if(request!=null){ // the control never goes inside if
>
> String name = request.getParameter("name");
> String surname = request.getParameter("surname");
>
> logger.info
> <http://logger.info>("Name::"+name+",Surname::"+surname);
> return "Name::"+name+",Surname::"+surname;
>
> }
> return "request is null"; // This gets returned always
>
> }
>
>
> My HTML looks like
>
> <html>
> <title>A Test Page
> </title>
>
> <form method="post" name="form1"
> action="https://localhost:8443/rest/submitform/">
> <table>
> <tr>
> <td>Name::
> </td>
>
> <td>
> <input type=text name="name" value="">
> </td>
> </tr>
>
> <tr>
> <td>Surname::
> </td>
>
> <td>
> <input type=text name="surname" value="">
> </td>
> </tr>
>
> <tr>
> <td align=center colspan=2>
> <input type=submit name="submit" value="submit">
> </td>
> </tr>
>
>
> </table>
> </form>
> </html>
>
> Any kind help will be appreciated.
>
> Thanks,
> Pranav Parikh
>
>
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Resteasy-developers mailing list
> Res...@li...
> https://lists.sourceforge.net/lists/listinfo/resteasy-developers
--
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com
|