0

I have created a text box in html and if the string entered by user is a alphabet it will not show any message ,else it should display a error message..These checking validations of textbox is done in java and called in jsp;
----------------------------------------------------------
a.html

<font size="4">Enter the search keyword:</font><input type="text" name="key" ><br> 
and also submit button is there which goes to main.jsp

----------------------------------------------------------------------
main.jsp

<%@page import="gaveshan.checking;"%> 
<% 
checking ch=new checking(); 
String trans=request.getParameter("key"); 
out.println(ch.ParseClean(trans)); 
session.setAttribute( "trans", trans ); 
%>

--------------------------------------------------------------------------------------
checking.java

package gaveshan; 
import java.awt.event.; 

public class checking 
{ public String ParseClean(String str) 
{ 

if(str.length()==100||str.length()==0) 
{ 
return "Enter String Properly"; 

} 
for(int i=0;i<str.length();i++) 
{ 
if(!(str.charAt(i)>65&&str.charAt(i)<122)) 
{ 
return "Enter String Properly"; 

} 
}

it is not givng any message when user enters the input in textbox
*it is not showing any error

Edited by peter_budo: Keep It organized - For easy readability, always wrap programming code within posts in [code] (code blocks)

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by javaAddict
0

First of all, write a main method in a separate class and test the ParseClean in order to see that it works.

Then post some more code of the a.html file so we can see how you submit the form.

And finally don't use this: out.println(ch.ParseClean(trans)); Use this:

<%@page import="gaveshan.checking;"%> 
<% 
checking ch=new checking(); 
String trans=request.getParameter("key"); 
session.setAttribute( "trans", trans ); 
%>
<%= ch.ParseClean(trans) %>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.