|
From: Pranav P. <pra...@gm...> - 2008-08-14 16:41:11
|
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("In submitform"+request);
if(request!=null){ // the control never goes inside if
String name = request.getParameter("name");
String surname = request.getParameter("surname");
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
|