Tuesday, November 29, 2011

How will you pass values from HTML page to the Servlet?

We can pass values to servlet from HTMLpage using "request.getParameter(string);" method.Which is a method in the HttpServletRequest interface.:from above answer we can retrieve value send from html in servlet.:a href="index.jsp?+name="+name+"":Any form field:Using form can send request to the servlet. Form attributes are name,nethod(post or get),action(servletpath/servletname). Then request can be got by using request.getParameter("name of the parameter(eg : text box name to get text box vale in servlet from html)").the return value is string.:request.getParameter("string") is the :using post method as follows:The values can be passed to the Servlet from HTML by various forms::We can pass values from a servlet to HTML page or JSP using request.getParameter(String[]); If you are using Struts Framework then we need to do some changes in StrutsConfig.xml while after global actions and Action Mapping tags we need to properly match Bean values i.e. Getters and setters and depending upon the Request on client side we can enhance our code and produce desired result. :by using post method we can send form values to the servlet then servlet receive the values from html form by using request.getParameter method and it stores the values to the database
Category:Java Interview Questions

No comments:

Post a Comment