i was jus trying to crete a form and if i submit the form the values should be displayed in the browser.
code is:
html file-

[/U]<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="firstjsp.jsp" method="get">

<table>
<tr><td><b>Name</b>
    <td><input type="text" name="name">

<tr><td><b>age</b>
    <td><input type="text" name="color">
</table>

<tr><td><b>address</b>
    <td><input type="text" name="address">
</table>

<input type="submit" value="Send">

</form>



</body>
</html>

jsp file-

<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="CSS/style.css" rel="stylesheet" type="text/css" />
<link href="CSS/tableStyle.css" rel="stylesheet" type="text/css" />
</head>

<body>



<table width="200" border="2" cellspacing="1">
  <tr>
    <td>Name:</td>
    <td><%= request.getParameter("name") %></td>
  </tr>
  <tr>
    <td>age:</td>
    <td><%= request.getParameter("color") %></td>
  </tr>
  <tr>
    <td>adds:</td>
    <td><%=request.getParameter("address") %></td>
  </tr>
</table>
</body>
</html>

code above would do that.

now the question is:
i want the form and the display of the entries should come one the same page?
wat should i use?
will ter b a role of scriplets for this?

You can have the action of the form be the same page. Like: <form action="" method="get"> The submit tag should be like this: <input type="submit" value="Send" name="submitTag" > Then at the same page; you can write that code wherever you want:

String name = request.getParameter("name");
....
String submit = request.getParameter("submitTag");

And at the place that you want to display your data:

<%
if (submitTag!=null) {
%>

<tr>
    <td>Name:</td>
    <td><%= name %></td>
  </tr>
  <tr>
    <td>age:</td>
    <td><%= color %></td>
  </tr>
  <tr>
    <td>adds:</td>
    <td><%= address %></td>
  </tr>

<%
}
%>

The first time the page loads the "request" is empty. Nothing has been submitted. So everything there is the request is null: request.getParameter

But when you submit to the same page the "request" now has data and they are not null. So you can use that check:
if (submitTag!=null)
In order to determine if the page has been submitted or not and display the data.

If nothing has been submitted everything that you get from the request would be null. So:
If the check with the submit doesn't work, you can use something else.
if (name!=null) {

....
}

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.