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

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) %>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.