In ASP.net MVC using the following snippet we can send the change password data to a controller. In the controller we can cast the posted data as ChangepasswordReq object and we can do our business. Now I am looking for the equivalent of this in jsp. How to communicate from the client side to the server side? I want to transfer a bigger form with number of controls.(I am using only html to build my pages). Any Help would be appreciable.
var ChangeReq = { CurrentPassword: epwd, NewPassword: newpwd }
var jsondata = JSON.stringify(ChangeReq)
$.ajax({
type: 'POST',
url: "/Account/ChangePassword",
cache: false,
timeout: 10000,
contentType: "application/json; charset=utf-8",
success: function (_results) {
//do something
},
error: function (_results) {
//do something
}
});
[HttpPost]
public ActionResult ChangePassword(ChangepasswordReq _ChangepasswordReq)
{
//do the business
}
public class ChangepasswordReq
{
public String CurrentPassword { get; set; }
public String NewPassword { get; set; }
}
I have tried the following. But in my case I am generating some controls dynamically. I cannot get them properly in the controller as the number of dynamic controls vary. Is there any better way in jsp for the url routing as in asp.net MVC.(better than @RequestMapping(value = “/ChangePassword”, method = RequestMethod.POST))
How to use jquery properly in jsp.(Please help me in client side and server side code)
@RequestMapping(value = "/ChangePassword", method = RequestMethod.POST)
public String home(@RequestParam("Currentpasswordtxtboxname") String Currentpassword,@RequestParam("NewPasswordtextboxname") String Newpassword, Locale locale, Model model) {
// do business
}
I found something Here.
In the server side we can get the parameters as
In the web.xml file