• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

is there a any validation API in java

 
anarkali perera
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 237
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am not familior with javascript.can you give me the good link for javascript validation?
 
Albareto McKenzie
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://tinyurl.com/yccuk45

;)
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64958
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
anarkali perera
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64958
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 237
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can we write this method using prepared statement?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64958
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's a better question for the JDBC forum.
 
anarkali perera
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok.i will post it.
 
anarkali perera
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64958
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's why you use SSL.
 
anarkali perera
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how can i use SSL in this example?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64958
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Setting up SSL on your server has nothing to do with your code. Time to do some research.
 
anarkali perera
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 237
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is the reference what i try to use?
http://tomcat.apache.org/tomcat-5.5-doc/ssl-howto.html
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
anarkali perera
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
anarkali perera wrote:i think it never ends?



So you haven't actually tried completing that process and gave up?
 
Hong Anderson
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
anarkali perera wrote:i think it never ends?

It has an end for sure. It's no funny game.
 
anarkali perera
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 237
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i did configuration.Is it need to do some thing to index.jsp to active ssl?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
...

Try accessing it using HTTPS?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic