STRUTS DEMO WITH AJAX USING jQUERY
When you submit the form the page itself is sent to the server. So it took a little bit time. To avoid this we can send the data rather than the whole page. We can provide such functionality to a page with the help of jQuery AJAX. For that we need to do some modifications to our demoInput.jsp page and we don't need demoOutput.jsp since we are going to show the output on the demoInput.jsp page itself. So, let us see how to provide
-----------------------------------------------------------------------
package demopack;
public class demoAction extends Action
{
public ActionForward execute(ActionMapping mapping,ActionForm form, HttpServletRequest request, HttpServletResponse response)throws IOException
{
demoForm demoform=(demoForm)form;
response.setContentType("text/text;charset=utf-8");
String b=demoform.getB();
String operation=demoform.getOperation();
calcbean bean1=new calcbean();
String r =bean1.calculate(a,b,operation);
String r1 = "Result is ......"+r;
out.println(r1);
}
//------------------------------------------
}
and calcbean.java and demoForm.java are same as in last example code.
*********************************************************************************