Jump to content

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 post
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 post
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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...