panaoui Posted February 28, 2008 Share Posted February 28, 2008 Because I'm new to the world of JSP....I have an easy problem....I think!I have a sevlet which is executed through an html page. Now with in that sevlet I diplay one form where the user can write some text and then because of the form I have a button to click (to post them). I want to show the data that the user wrote in the same page (below the form).I have make the action="" to the same page....After that what I have to do...?How can I say that when the button is click to show the data below the form...?Anyone?Thanks Link to comment Share on other sites More sharing options...
spoonraker Posted February 29, 2008 Share Posted February 29, 2008 Make your form's action the URL to the page you're on. So if you are on whatever.com/whatever.jsp, your form tag would be <form method="post" action="/whatever.jsp">Then below your form on that page you're going to want to use request.getParameter(String) method to pull the data from the submitted form(for this example, you're having the user enter their name) <form method="post" action="/whatever.jsp"> <!-- Form submits to the same page it's located -->Name : <input type="text" value="" name="name"/></form><%if(request.getParameter("name") != null && !request.getParameter("name").equals("")){ String name = request.getParameter("name"); out.print("Welcome, " + name);}%> Link to comment Share on other sites More sharing options...
panaoui Posted February 29, 2008 Author Share Posted February 29, 2008 Yes I understand what you are saying but...If I do that it appears me below the form all the values that I will enter with NULL and when I click submit button displays (removes the null) what I have enter. I want to have nothing until only when the user click the submit button of the form to appear the data...I hope you can understand what I'm tying to do... Link to comment Share on other sites More sharing options...
spoonraker Posted March 4, 2008 Share Posted March 4, 2008 sorry to take so long to reply, forgot about this thread, my badLook at my example, notice how I put the print command inside an if statement that checks for null data. You're going to have to do something like that for each piece of data. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.