The Artima Developer Community
Sponsored Link

Java Answers Forum
re: JSP page

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Mickey

Posts: 7
Nickname: internment
Registered: Feb, 2004

re: JSP page Posted: Feb 17, 2004 2:32 AM
Reply to this message Reply
Advertisement
Hi folks,
Below is a html page,bean,servlet and jsp page for the response. My problem is i cannot get the name i enter into the form in the HTML page to appear in the jsp page. The jsp page is being displayed but without the name....what am i doing wrong. Thanks for your help....



THIS IS THE HTML PAGE WITH THE FORM......!!!

<html>
<head>
<title>Register User HTML</title>
</head>

<body bgcolor="#ffffff">


<table border="0" width="700">
<tr>
<td width="150"> &nbsp; </td>
<td width="550"> <h1>Register User?</h1> </td>
</tr>
<tr>
<td width="150"> </td>
<td width="550">
<form action="http://localhost:8080/servlet/Controller" method="post">
<input type="text" name="name" size="25"> <br>
<input type="submit" value="Submit">
<input type="reset" value="Reset">
</td>
</tr> </form>
</table>
</body>
</html>



THIS IS PART OF THE SERVLET..........!!!

protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
String userName;
userName = request.getParameter("name");

response.setContentType("text/html");

HttpSession session = request.getSession(true);
session.setAttribute("userName", userName);

if (request.getParameter("name") != null ) {
gotoPage("/response.jsp",request,response);
}

}


THIS IS THE BEAN..............!!!

public class RegisterHandler {

private String username;

public RegisterHandler()
{
username = null;
}

public void setUsername( String name )
{
username = name;
}

public String getUsername()
{
return username;
}
}


THIS IS THE JSP RESPONSE PAGE.....!!!

<%@ page import="Register.RegisterHandler" %>
<jsp:useBean id="registerBean" scope="page" class="Register.RegisterHandler"/>
<jsp:setProperty name="registerBean" property="*"/>
</jsp:useBean>
<table border="0" width="700">
<tr>
<td width="150"> &nbsp; </td>

<td width="550">

<h1>Names entered is: <jsp:getProperty name="registerBean"
property="username" />!
</h1>

</td>
</tr>
</table>

Topic: How To Get The Correct Outcome Previous Topic   Next Topic Topic: jdk 1.4 not installing

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use