Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

reagarding jsp problem

 
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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 ]
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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:
https://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.
 
A Babu
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
how can i make my code as UBB code.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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.
 
    Bookmark Topic Watch Topic
  • New Topic