Hi I am new to JSP, if some could help me in understanding what is wrong in this code

<%String newname="hi"; %>
<input type=text value="<%=newname %>" name="newname">


String modifyurl = "delete.jsp?newname="+newname+"";
out.println("<td><a href ="+modifyurl+">Modify</a></td></tr><br>");

so when i print newname it always says null... please help



Edited by peter_budo: Keep It Clear - Do wrap your programming code blocks within [code] ... [/code] tags

7 Years
Discussion Span
Last Post by parry_kulk

One thing you must always remember while dealing JSP or any server side scripting is that the server side code is executed first at the server than the resulted HTML is sent to the browser.
So in the code snippet given above all the java code between <%= %>, and <% %> will be executed on the web-server first. So any request.getParameter() statement will be executed before the page is rendered. You are getting the null value because the value of "newname" input field is not submitted yet.
Only after you submit a page containing the "newname" input field you will be able to read it using request.getParameter("newname")
Hope this helps

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.