• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Where to write Validation

 
Rajendra Prakash
Ranch Hand
Posts: 293
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 151
Java MyEclipse IDE Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
write in the DAO that is responsible for database communication...can write in the same jsp page to .. its up to your application architecture
 
Rajendra Prakash
Ranch Hand
Posts: 293
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to write in the same jsp page.
 
akhter wahab
Ranch Hand
Posts: 151
Java MyEclipse IDE Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to a more appropriate forum.
 
Rajendra Prakash
Ranch Hand
Posts: 293
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 293
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 151
Java MyEclipse IDE Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 293
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Posts: 293
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its not struts ok. Give me that single line, how to get username and pwd in service method
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 293
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the x --> scope of the actionform in struts. if you want struts then switch to struts framework
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic