aspose file tools*
The moose likes JSP and the fly likes reagarding jsp problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Reply locked New topic
Author

reagarding jsp problem

A Babu
Ranch Hand

Joined: Nov 28, 2005
Posts: 114
hi all,


see my code first.

i wrote 1 java bean and 2 jsp files.they are,

package com;
public class Mybean
{
private String empname;
private int empnumber;

public String getEmpname()
{
return empname;
}

public int getEmpnumber()
{
return empnumber;
}

public void setEmpname(String empname)
{
this.empname=empname;
}

public void setEmpnumber(int empnumber)
{
this.empnumber=empnumber;
}

};
this is bean file.
<HTML>
<HEAD>
<TITLE>A SimpleForm</TITLE>
</HEAD>

<BODY BGCOLOR = "WHITE">
<FORM METHOD="POST" ACTION="second.jsp">

<P>
Enter Employee Name:<INPUT TYPE="TEXT" NAME="empname"></INPUT>

<P>
Enter Emp No:<INPUT TYPE="TEXT" NAME="empnumber"></INPUT>

<P>
<INPUT TYPE="SUBMIT" value="submit">
<INPUT TYPE="RESET" value="RESET">
</FORM>


<jsp:useBean id="mybean" class="com.Mybean" scope="session"/>

<jsp:setProperty name="mybean" property="*"/>

Employee Name is:
<jsp:getProperty name="mybean" property="empname"/>


<P>
Employee Number is:
<jsp:getProperty name="mybean" property="empnumber"/>




</BODY>
</HTML>
this is first.jsp

and

<HTML>
<HEAD>
<TITLE>This is second Jsp page</TITLE>
</HEAD>
<BODY>
<%@ page language="java"%>
<%!String name="";%>
<%!String number="";%>

<%
name=request.getParameter("empname");
session.putValue("empname", name);
number=request.getParameter("empnumber");
session.putValue("empnumber",number);
String values[]=session.getValueNames();
for (int i=0; i<values.length; i++) {%>
<%=session.getValue(values[i])%>
<%}%>


</BODY>
</HTML>

this is second.jsp

if i run this one
first.jsp displays oneform
wich ask name and number from user
if the user enteres those values are set in bean and display in browser with the help of second.jsp.

my problem is if again i back to form and fill name and no with another values then i click submit button.

the o/p is is printed this values only.
i want previous values also need to print.because we are using the session in second.jsp.

for this purpose only i am using the second.jsp otherwise no use with second.jsp.

please help me to print all the values in the session for Name variable and Number variable.
[ November 29, 2005: Message edited by: Bear Bibeault ]

Thanks,
www.Admakr.in
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Babu,

Two things:

First, when posting more than a line or two of your code, it is a good idea to wrap the code in UBB CODE tags. This will preserve your indenting and make it much easier to read. If it's easier to read, more people will read it which means you are more likely to get help.

Second, this looks like a continuation of:
http://www.coderanch.com/t/288549/JSP/java/jsp-data-store
It would be better to add the new information (in this case, the actual code) to the original thread than to start a new one with the same question.

As to your question, if you want to the user to be able to fill the form out multiple times within one session, you will want to create a method that will generate a new userBean for each form submission and add those beans to a list. You can then use JSTL to iterate through the list for display purposes.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
A Babu
Ranch Hand

Joined: Nov 28, 2005
Posts: 114
how can i make my code as UBB code.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

There is a button on the edit screen labeled "CODE".
It will create the tags for you.
Just paste your code between the CODE and /CODE tag.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: reagarding jsp problem