Reputation: 69
You know that we need a java class for writing a custom tag library. So I want to write my own tag lib. But I must take a data from the html form in the jsp page. How can i get a data from a html form to my java class?
Upvotes: 0
Views: 2932
Reputation: 23413
You need to retrieve the HttpServletRequest
from your page context. In your tag library just use this to get it:
PageContext pageContext = (PageContext) getJspContext();
HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
For e.g.: You have a html form in your JSP page:
<form action="/someServlet">
<input type="text" value="yourValue" name="yourParameterName"/>
</form>
To get your parameter use:
String yourValue = request.getParameter("yourParameterName");
Upvotes: 1