0

I tried to do in JSP action will determine the value of a text field and saw no action request.setParameter. I tried to search online solutions and unfortunately I did not find.

I'd love to help, thanks in advance.

Ofir
  • 98
  • 1
  • 1
  • 10
  • 1
    Do you want to sanitize a full HTTP request (though this should not utterly be required in your use-case)? There is no such method as `request.setParameter()` associated with an `HttpServletRequest` class (This is deliberate). If you want to modify request parameters then, you need to customize/sanitize `HttpServletRequest` itself by wrapping it around `HttpServletRequestWrapper` basically by using a `Filter`. [Example](http://stackoverflow.com/q/1413129/1391249). – Tiny Jan 01 '15 at 15:07

2 Answers2

0

request.setParameter - is relevant when you're putting some parameter inside the HTML header.
In order to set the text inside the text field you should have a look here: http://www.w3schools.com/tags/tag_input.asp

roeygol
  • 4,908
  • 9
  • 51
  • 88
0

The input is sent to whatever the your forms 'action' attribute is. Lets say you have the following code

<form action="login.jsp" method="post">
    <lable><b>Username</b></label>
    <input type="text" name="username">
    <label><b>Password</b></label>
    <input type="password" name="password">
    <button type="submit">Login</button>
</form>

This means that, when your form is submitted, your login.jsp receives a POST request with those variables, these are accessible via the request (HttpServletRequest) object

For example, with the above code, you could use request.getParamater("username") to get the input supplied in the username field.

Tiny
  • 27,221
  • 105
  • 339
  • 599
Zachary Craig
  • 2,192
  • 4
  • 23
  • 34