<font color=red>Help me to solve this</font>
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   sabu_vs
Posted On:   Monday, May 13, 2002 02:32 AM

Hi I have a jsp program that accepts user input[name and email]. In my program I declared the variables name and email. I want to create a bean that validates the user input and assign values to the respective variables.This bean should call like this <% validte() or validte(request) %> Then the bean begins to read the request. if the field " name " has a value then it assign this value to the variable " name " which is declared in the calling jsp page. If there is no curresponding variable then leave that field.    More>>

Hi



I have a jsp program that accepts user input[name and email].


In my program I declared the variables name and email.


I want to create a bean that validates the user input and assign

values to the respective variables.This bean should call like this





<%


validte()

or

validte(request)


%>




Then the bean begins to read the request. if the field " name " has a value

then it assign this value to the variable " name " which is declared

in the calling jsp page. If there is no curresponding variable then leave that field.



But I donot know how to do it.
Does REFLECTION helps to solve this.
Could you pls help me.Could you pls include some sample codes




thanks for your time


sabu

   <<Less

Re: <font color=red>Help me to solve this</font>

Posted By:   gayathri_meenakshi  
Posted On:   Wednesday, May 15, 2002 02:49 AM

Hi,

Hope the following samples help...

Bean Class Employee

package test;


import java.io.*;

public class Employee implements java.io.Serializable

{
public String name = null;
public String email = null;

public Employee(){};

public void setName(String name)
{
this.name = name;

}
public String getName()
{
return this.name;
}
public void setEmail(String email)
{
this.email = email;

}
public String getEmail()
{
return this.email;
}

public validate()
{
//include check here

}


}


Jsp File


<%@ page import="java.sql.*" %>
<%
String name = "gaya";
String email = "gy@yaoo";
%>




<%
out.println(trial.getName());
out.println(trial.getEmail());
trial.validate();
%>


Cheera ,

Gaya
About | Sitemap | Contact