aspose file tools*
The moose likes Tomcat and the fly likes is there a any validation API in java 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 » Products » Tomcat
Bookmark "is there a any validation API in java" Watch "is there a any validation API in java" New topic
Author

is there a any validation API in java

anarkali perera
Ranch Hand

Joined: Sep 10, 2009
Posts: 237
this is a small registration aplication

this is the index.jsp file


this is a servlet


this is a database connector


this is a abstract class


my question is how to validate the user inputs
As a example how guarantee that name doesn't include any numbers.....age only include numbers?
is there a any validation API in java?
Albareto McKenzie
Ranch Hand

Joined: Apr 08, 2009
Posts: 298
You can validate it in Java, of course, but as it's a Server side language you will have to send the info to the server, validate it in Java and then send to the browser the appropiate data (registration succeed or not succeed or whatever). Fos simple validations you can use javascript, before submitting validate that the age is a number and is not !@rt, for example.
anarkali perera
Ranch Hand

Joined: Sep 10, 2009
Posts: 237
i am not familior with javascript.can you give me the good link for javascript validation?
Albareto McKenzie
Ranch Hand

Joined: Apr 08, 2009
Posts: 298
http://tinyurl.com/yccuk45

;)
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61432
    
  67

Be aware that JavaScript validation on the client is not a suitable replacement for validation on the server. Your data must always be validated on the server regardless of whether you perform client-side validation or not.

As this is primarily a query regarding validation libraries, I've moved it to the Open Source Projects forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
anarkali perera
Ranch Hand

Joined: Sep 10, 2009
Posts: 237
now i edit the code.

this is the index.jsp


this is the abstract class

this si the welcome class


this is the database class


Now there is a way to authentication machanism.
now i need these ones
1)how avoid sql injection when login?
2)good encription for password and how to save encripted data in mysql ??
3) is there any other ways to improve the quality of this code?
Albareto McKenzie
Ranch Hand

Joined: Apr 08, 2009
Posts: 298
just create a method private boolean validate(String element) and check that your String doesn't contain any strange character...
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61432
    
  67

1) Be sure to use prepared statements.

2) Hash the password using an MD5 or SHA hash. Store the hashed variant. Hash incoming passwords and compare hashes.
anarkali perera
Ranch Hand

Joined: Sep 10, 2009
Posts: 237
can we write this method using prepared statement?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61432
    
  67

That's a better question for the JDBC forum.
anarkali perera
Ranch Hand

Joined: Sep 10, 2009
Posts: 237
ok.i will post it.
anarkali perera
Ranch Hand

Joined: Sep 10, 2009
Posts: 237
I have problem on server side validation.
user type his username and password on browser.
so if i use server on encription to password the password hacker can get the password between client machine and server.because client machine to server password goes a normal text.
is it true?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61432
    
  67

That's why you use SSL.
anarkali perera
Ranch Hand

Joined: Sep 10, 2009
Posts: 237
how can i use SSL in this example?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61432
    
  67

Setting up SSL on your server has nothing to do with your code. Time to do some research.
anarkali perera
Ranch Hand

Joined: Sep 10, 2009
Posts: 237
ok
i found tutorial.But it says "Create a certificate keystore by executing the following command:"

%JAVA_HOME%\bin\keytool -genkey -alias tomcat -keyalg RSA

i copy this command and past the comand line and run.Error.
how to execute this command.
anarkali perera
Ranch Hand

Joined: Sep 10, 2009
Posts: 237
this is the reference what i try to use?
http://tomcat.apache.org/tomcat-5.5-doc/ssl-howto.html
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42285
    
  64
If you have questions about errors you're getting, then it would be extremely helpful to know what those errors are. Post them in full, along with detailed information what you're doing.


Ping & DNS - my free Android networking tools app
anarkali perera
Ranch Hand

Joined: Sep 10, 2009
Posts: 237
first i go to the
C:\Program Files\Java\jdk1.6.0\bin using command line .
then i type this on cmd.
keytool -genkey -alias tomcat -keyalg RSA

then it ask the password.I give the password and i give changeit as mentioned in site.
then it ask re type password and i give changeit again.
then it ask "What is your first and last name " ,"What is the name of your organizational unit",What is the name of your organization?................i think it never ends?
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10207
    
166

anarkali perera wrote:i think it never ends?



So you haven't actually tried completing that process and gave up?


[My Blog] [JavaRanch Journal]
Hong Anderson
Ranch Hand

Joined: Jul 05, 2005
Posts: 1936
anarkali perera wrote:i think it never ends?

It has an end for sure. It's no funny game.


SCJA 1.0, SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJP 5.0, SCEA 5, SCBCD 5; OCUP - Fundamental, Intermediate and Advanced; IBM Certified Solution Designer - OOAD, vUML 2; SpringSource Certified Spring Professional
anarkali perera
Ranch Hand

Joined: Sep 10, 2009
Posts: 237
it is ok.
i uncomment the 8443 also.Now is it ok.How should i check now it support ssl?

<-- Define a SSL Coyote HTTP/1.1 Connector on port 8443 -->
<!--
<Connector
port="8443" minProcessors="5" maxProcessors="75"
enableLookups="true" disableUploadTimeout="true"
acceptCount="100" debug="0" scheme="https" secure="true";
clientAuth="false" sslProtocol="TLS"/>
-->
anarkali perera
Ranch Hand

Joined: Sep 10, 2009
Posts: 237
i did configuration.Is it need to do some thing to index.jsp to active ssl?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

...

Try accessing it using HTTPS?
 
jQuery in Action, 2nd edition
 
subject: is there a any validation API in java