wood burning stoves 2.0*
The moose likes JSP and the fly likes Where to write Validation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Where to write Validation" Watch "Where to write Validation" New topic
Author

Where to write Validation

Rajendra Prakash
Ranch Hand

Joined: Sep 10, 2009
Posts: 293
I am new to web Application development. In jsp page am entering name PRAKASH ,
but the name already exists in database means where i have to write validations for this criteria.
akhter wahab
Ranch Hand

Joined: Mar 02, 2009
Posts: 151

write in the DAO that is responsible for database communication...can write in the same jsp page to .. its up to your application architecture


Start Earning Online||Start Earning Using Java
Rajendra Prakash
Ranch Hand

Joined: Sep 10, 2009
Posts: 293
How to write in the same jsp page.
akhter wahab
Ranch Hand

Joined: Mar 02, 2009
Posts: 151

again on your bussiness logic....... send the name parameter to the database get the value of the in the jsp page as boolean if it exists then get true ..if get true than show that it is already exists
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39393
    
  28
Moving to a more appropriate forum.
Rajendra Prakash
Ranch Hand

Joined: Sep 10, 2009
Posts: 293
I understand the logic which you said. I am new to development.
Can you say from which file you send request to database ( )
and which file you retrieve data
Rajendra Prakash
Ranch Hand

Joined: Sep 10, 2009
Posts: 293
suppose am using jsp,servlet , struts , hibernate. From which file i send request to DB.
In which file i request data from DB
akhter wahab
Ranch Hand

Joined: Mar 02, 2009
Posts: 151

well in more appropriate way jsp use only for geting info and receive perameter in the servlets and a simple java class is used for database connectivity and methods make the object of java class in servlet and send response back to jsp page
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Rajendra Prakash wrote:suppose am using jsp,servlet , struts , hibernate. From which file i send request to DB.
In which file i request data from DB

A service class inside the action or the action form--it kind of depends.
Rajendra Prakash
Ranch Hand

Joined: Sep 10, 2009
Posts: 293
previously i used following code to validate username and password.
But now i am using struts , how can i get username and pwd instead of reques.getParameter()
I know there is getUsername() and getPassword() in ActionForm.
My question is , i need single line how to assign getUsername() and getPassword() to string variable.



Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575



there is a redundant casting. I think it is not a struts application,you have to get username in service method only like above.

I do the form(user fields) validation using methods in servlet. and business validation in DAO
Rajendra Prakash
Ranch Hand

Joined: Sep 10, 2009
Posts: 293
Its not struts ok. Give me that single line, how to get username and pwd in service method
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Rajendra Prakash wrote:Its not struts ok. Give me that single line, how to get username and pwd in service method

what do you mean by single line?
this is the way :
Rajendra Prakash
Ranch Hand

Joined: Sep 10, 2009
Posts: 293
How to do the same in struts.If you use struts means there will be ActionForm(getUsername () , getPwd() )
which eliminates request.getParameter() method.


From the above code what is " x ".
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

the x --> scope of the actionform in struts. if you want struts then switch to struts framework
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Where to write Validation