I’m trying to pass parameter to jsp to servlet. And my code is :
Server side :
JavaScript
x
String kullanici = (String)request.getParameter("onaylayici");
JSP side :
JavaScript
<input type="text" name ="onaylayici">
When i run it on localhost kullanici
variable comes null
. Any solution ?
EDİT :
JavaScript
<form name = "main" method = "POST">
<td class="summary"><b>İsteği Onaylanacak Kişi :
<input type="text" name ="onaylayici"> <br>
</form>
Advertisement
Answer
I think you mean that you want to go FROM a jsp TO a servlet. If that’s the case, look the action attribute:
JavaScript
<form action='/MyServlet' >
</form>
If you are going FROM a Servlet TO a jsp then you could reuse current request attribute. You do it by settng the value directly in the . Something similar to this:
JavaScript
request.setAttribute("onaylayici", request.getParameter("onaylayici"));
in your servlet. Then, in your jsp this:
JavaScript
<input name='onaylayici' type='text' value='${requestScope["onaylayici"]}'/>