Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

checking textbox through java class which is called in jsp  RSS feed

 
adity kommu
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



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
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66205
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please UseCodeTags (⇐ this is a link)
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66205
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A few things:
  • The <font> tag is deprecated. Don't use it. Use CSS for styling.
  • Using Java code in a JSP is a discredited practice. Don't do it. Put java code in Java classes.
  • Follow conventions. Class names should be in mixed case. e.g. Checking, not checking.
  • Follow conventions. Method names should start with a lowercase character. e.g. parseClean, not ParseClean.


  • All that said, what is happening? Just telling us it doesn't work isn't helpful. Please read: ItDoesntWorkIsUseless
     
    It is sorta covered in the JavaRanch Style Guide.
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!