Reputation: 1243
I have created a servlet that passes a string variable strname to a JSP page. The JSP recieves it into a variable "strname" using
request.getAttribute("strname")
Now I want to display this inside the text field of a form
<form action="LogoutServlet" method="post">
<% String strname =(String)request.getAttribute("uname");%>
Username:<input type="text" name="username" value="${username}"/>
</form>
but it is displaying "username" int the text field. How can I display the strname var in the text ?? Please Help
Upvotes: 2
Views: 18516
Reputation: 94653
You may use EL expression (read the FAQ).
<input type="text"
value="${requestScope.strname}"/>
or
<input type="text"
value="${strname}"/>
or
<input type="text"
value="${param.username}"/>
or JSTL <c:out />
<c:out value="${strname}"/>
Upvotes: 2
Reputation: 8777
Using $
you can get the value. For ex :
<input type="text" name="strname" value="${strname}" />
(Assuming you are getting correct value in strname variable.)
Upvotes: 2
Reputation: 985
You can use the jstl way to get the value stores in the request e.g
<input type="text" value="${uname}">
Upvotes: 0