Jump to content

JSP


panaoui
 Share

Recommended Posts

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

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...