Skip to content
Advertisement

JSP input comes null to servlet

I’m trying to pass parameter to jsp to servlet. And my code is :

Server side :

String kullanici = (String)request.getParameter("onaylayici");

JSP side :

<input type="text" name ="onaylayici">

When i run it on localhost kullanici variable comes null. Any solution ?

EDİT :

<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:

<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:

request.setAttribute("onaylayici", request.getParameter("onaylayici"));

in your servlet. Then, in your jsp this:

<input name='onaylayici' type='text' value='${requestScope["onaylayici"]}'/>
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement