Problem with JSP and servlet in Tomcat

hello all,
I have made a simple hello world in Eclipse and Tomcat, it works well on my localhost, but now that I try to run it on the server in our lab I got this exception:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Implementing class
     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:272)
     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
java.lang.IncompatibleClassChangeError: Implementing class
     java.lang.ClassLoader.defineClass1(Native Method)
     java.lang.ClassLoader.defineClass(ClassLoader.java:620)
     java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
     org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1815)
     org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:869)
     org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1322)
     org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1201)
     org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:127)
     org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:65)
     java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
     java.lang.Class.getDeclaredConstructors0(Native Method)
     java.lang.Class.privateGetDeclaredConstructors(Class.java:2328)
     java.lang.Class.getConstructor0(Class.java:2640)
     java.lang.Class.newInstance0(Class.java:321)
     java.lang.Class.newInstance(Class.java:303)
     org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:148)
     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
I have transfered the web.xml file and lib and classes folder in a WEB-INF folder and also all the JSP files. I can see he JSP file, but the 'hello worl' does not work and gives this exception!
Does any one have any idea what could be the problem?
thanks a lot
Mitra

seems the web Server code previously loaded a class only when it was used rather than when it was referenced,
ask your question in the tomcat-user mailing ! !!!

Similar Messages

  • Cookie Problem  With JSP and Tomcat

    I have a tiny web application developed for my project thing.
    I am facing a problem while maintaining sessions with Cookie. I use Tomcat 3.2.1 Web Server and JSP 1.2 Specifications for my web application.
    I have created a page which creates a cookie and stores it in the client's PC, so when the same client visits the site, he can be remembered. Now while surfing the site in the same session, the site remembers the client. But once the client closes the browser and tries connecting to the site, he cannot be remembered. So I took a look into Temporary Internet Files of the client PC and found no cookie there. So where the cookie gets created and why does it disappears with the session. I have set a time limit of 1 year in the cookie.
    Now is that a Problem with Tomcat or with the configuration settings of IE in the client PC?? Or something else???
    Reply me Soon...

    Thanks for your reply.
    following is the code for how do i create a cookie...
    <%
         String custno = custBean.createPreferred();
         Cookie c = new Cookie("pc", custno);
         c.setVersion(1);
         c.setPath("/");
         c.setComment("PreferredCustomer");
         c.setDomain("think_machine");
    //think_machine is the name of the Web Server(Tomcat)
         c.setMaxAge(365*24*60*60);
         response.addCookie(c);
    %>
    And the code to read a cookie is..
         String custID = null;
         Cookie[] cookies = request.getCookies();
         for(int i = 0; i < cookies.length; i++)
              if(cookies.getName().equals("pc"))
                   custID = cookies[i].getValue();
                   break;
    One more thing I would like to let you know, that i access this from the same PC on which the Web Server is installed. Means the Server and the client are both one and the same PC.

  • Problems with JSP and Tag Libraries in JBoss using Tomcat 5.5.9

    Hi,
    I am experiencing a really weird situation here. When running a deployed EJB3 ear application in a JBoss 4.0.3sp1 application using Tomcat service 5.5.9, Jasper is unable to compile any JSP file using Tag Libraries. To be more precise, when generating the Java source file (looking in the 'work' directory) everything in the file after the first occurance of a Tag Library usage is commented out (with "//"), causing the Java source to be invalid and outputs an error when accessing the page via a browser saying:
    "org.apache.jasper.JasperException: Unable to compile class for JSP
    Generated servlet error:
    Syntax error, insert "}" to complete ClassBody
    Generated servlet error:
    Syntax error, insert "}" to complete Block
    Generated servlet error:
    Syntax error, insert "finally" to complete TryStatement
    Generated servlet error:
    Syntax error, insert "}" to complete MethodBody"
    etc... where every error row is a suggestion of steps to take to make the source file valid. (of course).
    The Tag Library jar files are located in the web application WEB-INF/lib folder as they should be. The descriptive Tag Library Definition files (tld:s) are located in the WEB-INF folder and every JSP file references these tld files directly via this path (WEB-INF/).
    Any hints are most appreciated!!
    Cheers!
    /Henrik

    Hi,
    I am experiencing a really weird situation here. When running a deployed EJB3 ear application in a JBoss 4.0.3sp1 application using Tomcat service 5.5.9, Jasper is unable to compile any JSP file using Tag Libraries. To be more precise, when generating the Java source file (looking in the 'work' directory) everything in the file after the first occurance of a Tag Library usage is commented out (with "//"), causing the Java source to be invalid and outputs an error when accessing the page via a browser saying:
    "org.apache.jasper.JasperException: Unable to compile class for JSP
    Generated servlet error:
    Syntax error, insert "}" to complete ClassBody
    Generated servlet error:
    Syntax error, insert "}" to complete Block
    Generated servlet error:
    Syntax error, insert "finally" to complete TryStatement
    Generated servlet error:
    Syntax error, insert "}" to complete MethodBody"
    etc... where every error row is a suggestion of steps to take to make the source file valid. (of course).
    The Tag Library jar files are located in the web application WEB-INF/lib folder as they should be. The descriptive Tag Library Definition files (tld:s) are located in the WEB-INF folder and every JSP file references these tld files directly via this path (WEB-INF/).
    Any hints are most appreciated!!
    Cheers!
    /Henrik

  • Problem with JSP and Java Servlet Web Application....

    Hi every body....
    I av developed a web based application with java (jsp and Java Servlets)....
    that was working fine on Lane and Local Host....
    But when i upload on internet with unix package my servlets and Java Beans are not working .....
    also not access database which i developed on My Sql....
    M using cpanel support on web server
    Plz gave me solution...
    Thanx looking forward Adnan

    You need to elaborate "not working" in developer's perspective instead of in user's perspective.

  • Problems with JSP and MySql bean.

    Hi,
    I'm new to JSP and I'm having some problems with it. I'm trying to do a simple login where a java class (bean?) handles the SQL injektion. I have deployed the page on tomcat and it works fine, except that the sqlinjektion does basically nothing. I have installed the mysql driver. I think there is something wrong with the java class, or the way im calling it. It does not produce any error. But its like it would never actually process the java code, because ive tried to append things to error string to see what is going on, nothing happens. everything stay null, no exceptions are thrown. If I implement the code to JSP itself, it does load the driver and print exception that there is no connection to database (which is correct). What am I missing? Code follows:
    the sqlhandler:
    public abstract class SqlInjektor {
         private static String Database = "*****";
         private static String serverName = "localhost:3306";
         private static String usrName="******";
         private static String passw="******";
         * @return Connection
         public static Connection createConnection(String error){
              Connection mySqlCon = null;
              try{
                   Class.forName("com.mysql.jdbc.Driver").newInstance();
              catch(Exception E){
                   PrintWriter out = response.getWriter();
                   out.println("lol");
              String url = "jdbc:mysql://" + serverName + "/" + Database + "?user=" + usrName + "&password=" + passw;
              try{
                   mySqlCon = DriverManager.getConnection(url);
              catch (Exception E){
                   E.printStackTrace(System.out);
              return mySqlCon;
         * Metodi saa sy�tteen��n SQL komennon, jonka se suorittaa sek� palauttaa komennon tulokset.
         * @param command
         * @return ResultSet
         public static ResultSet querySQL(String command,String error, Connection con){
              ResultSet rs = null;
              try{
                   Statement stmt = con.createStatement();
                   rs = stmt.executeQuery(command);
              catch(Exception E){
                   E.printStackTrace(System.out);
              return rs;
    the jsp page:
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@ page isErrorPage="false" %>
    <%@ page import="java.sql.*" %>
    <%@page import="ot3.User"%>
    <%@page import="ot3.SqlInjektor"%>
    <%@page import="Javax.servlet.jsp.*"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>vastaanotto</title>
    </head>
    <body>
    <%!      String id;
         String password;
         String error = new String("Error!\n");
         User user;
    %>
    <%      user = new User();
         session.putValue("currentUser",user);
         id = request.getParameter("authName");
    password = request.getParameter("Password");
         Connection conn=null;
         ResultSet rs=null;
         conn = SqlInjektor.createConnection(error);
         if(conn!=null){
              out.println("conn ok!");
              rs = SqlInjektor.querySQL("SELECT * FROM user WHERE id='" + id +"' AND password='" + password+"' COLLATE latin1_bin;",error,conn);}
         try {
              if (rs!= null && rs.next()){
                   user.setID(rs.getInt("id"));
                   user.setName(rs.getString("name"));
                   user.setPassword(rs.getString("password"));
                   user.setClearance(rs.getInt("clearance"));
                   if(rs.getString("addedby")!=null)
                        user.setAdder(rs.getInt("addedby"));
                   if(rs.getString("lastmodifier")!=null)
                        user.setModifier(rs.getInt("lastmodifier"));
                   rs.close();%>
                   ONNISTU!
              <%}
              else {
                   out.println(error);     
         } catch (SQLException e) {
              out.println(e.getMessage());
         }%>
    </body>
    </html>

    Hi,
    I'm new to JSP and I'm having some problems with it. I'm trying to do a simple login where a java class (bean?) handles the SQL injektion. I have deployed the page on tomcat and it works fine, except that the sqlinjektion does basically nothing. I have installed the mysql driver. I think there is something wrong with the java class, or the way im calling it. It does not produce any error. But its like it would never actually process the java code, because ive tried to append things to error string to see what is going on, nothing happens. everything stay null, no exceptions are thrown. If I implement the code to JSP itself, it does load the driver and print exception that there is no connection to database (which is correct). What am I missing? Code follows:
    the sqlhandler:
    public abstract class SqlInjektor {
         private static String Database = "*****";
         private static String serverName = "localhost:3306";
         private static String usrName="******";
         private static String passw="******";
         * @return Connection
         public static Connection createConnection(String error){
              Connection mySqlCon = null;
              try{
                   Class.forName("com.mysql.jdbc.Driver").newInstance();
              catch(Exception E){
                   PrintWriter out = response.getWriter();
                   out.println("lol");
              String url = "jdbc:mysql://" + serverName + "/" + Database + "?user=" + usrName + "&password=" + passw;
              try{
                   mySqlCon = DriverManager.getConnection(url);
              catch (Exception E){
                   E.printStackTrace(System.out);
              return mySqlCon;
         * Metodi saa sy�tteen��n SQL komennon, jonka se suorittaa sek� palauttaa komennon tulokset.
         * @param command
         * @return ResultSet
         public static ResultSet querySQL(String command,String error, Connection con){
              ResultSet rs = null;
              try{
                   Statement stmt = con.createStatement();
                   rs = stmt.executeQuery(command);
              catch(Exception E){
                   E.printStackTrace(System.out);
              return rs;
    the jsp page:
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@ page isErrorPage="false" %>
    <%@ page import="java.sql.*" %>
    <%@page import="ot3.User"%>
    <%@page import="ot3.SqlInjektor"%>
    <%@page import="Javax.servlet.jsp.*"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>vastaanotto</title>
    </head>
    <body>
    <%!      String id;
         String password;
         String error = new String("Error!\n");
         User user;
    %>
    <%      user = new User();
         session.putValue("currentUser",user);
         id = request.getParameter("authName");
    password = request.getParameter("Password");
         Connection conn=null;
         ResultSet rs=null;
         conn = SqlInjektor.createConnection(error);
         if(conn!=null){
              out.println("conn ok!");
              rs = SqlInjektor.querySQL("SELECT * FROM user WHERE id='" + id +"' AND password='" + password+"' COLLATE latin1_bin;",error,conn);}
         try {
              if (rs!= null && rs.next()){
                   user.setID(rs.getInt("id"));
                   user.setName(rs.getString("name"));
                   user.setPassword(rs.getString("password"));
                   user.setClearance(rs.getInt("clearance"));
                   if(rs.getString("addedby")!=null)
                        user.setAdder(rs.getInt("addedby"));
                   if(rs.getString("lastmodifier")!=null)
                        user.setModifier(rs.getInt("lastmodifier"));
                   rs.close();%>
                   ONNISTU!
              <%}
              else {
                   out.println(error);     
         } catch (SQLException e) {
              out.println(e.getMessage());
         }%>
    </body>
    </html>

  • Help with jsp and servlets(litterature)

    I'm planning on converting a asp website to jsp and I need to figure out the following:
    1: servlet that gives out connection objects from a pool and manages "lost" connections to a mysql db
    2: a bean that has getConnection and closeConnection that is used on every jsp page.
    3: servlet/bean that can check size/dimesions/filetype on a remote url image
    4: Figure out what users are logged in at every given moment. result: x users are on, these are user1, user2, user3. automatic removal when session runs out. probably need a servlet for this.
    I got these books:
    deitel java how to program 3rd edition
    deitel advanced java 2 platform how to program
    The last book has a servlet and jsp section ut I suspect that java has evolved since then so thats why I'm asking if you have any other suggestions that offer more than 2 chapters. Its really basic the stuff i have :)
    Its been 3 years since I've touched java so i hope you guys can recomend jsp/servlet books that can answer these questions for me and help me get started with this project?
    Thanks :)

    1. apache dbcp commons library.
    http://jakarta.apache.org/commons/dbcp/
    2. tomcat DataSource, which already has the dbpc logic incorporated into it.
    http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html
    3. no idea, google may help
    4. HttpSessionBindingListener. This allows you to monitor when a bean (such as a User bean) is added to the session and when it is removed from the session. This way you can track yourself which users are online.
    http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/http/HttpSessionBindingListener.html

  • Best websites with JSP and Servlets

    I would like to see some examples of the best well-known websites realised with jsp & servlets.(if it's possible some awarded ones)
    thx

    This forum is using JSPs. I can see post.jsp in the URL as I type this. Famous enough?
    I believe eBay is 100% J2EE:
    http://www.theserverside.com/home/thread.jsp?thread_id=8906
    MOD

  • Problem with jsp and tomcat

    Hi ,
    I am trying to retrieve data from mysql server using Tomcat webserver of java web services developers pack. i wrote an html page that sends the account_no and password of my program to a JSP page which retrieve data from MySQL server to check whether the account no and password is valid or not . but when i start tomcat and run the html page and submit the onformation the Tomcat gives an error. i am attaching my full programs here. please someone help me.
    mybank.html:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE> My Bank </TITLE>
    </HEAD>
    <BODY>
    <h1>Please Enter Your Account Number and Password</h1>
    <form action="mybank.jsp" method="post">
    <h2>Account Number:</h2>
    <input type="text" name="accno" maxlength="10" size="10"></br>
    <h2>Password:</h2>
    <input type="text" name="pass" maxlength="8" size="8"></br>
    <input type="submit" value="SUBMIT YOUR INFO">
    </form>
    </body>
    </html>
    mybank.jsp:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <%@ page import="java.sql.*" %>
    <HTML>
    <HEAD>
    <TITLE> My Bank JSP </TITLE>
    </HEAD>
    <BODY>
    <% int acc_no = request.getParameter("accno");
    String password=request.getParameter("pass");
    class.forName(com.mysql.jdbc.Driver);
    Connection con= DriveManager.getConnection("jdbc:mysql:///password","root", "firehouse" );
    Statement stmt = con.createStatement();
    ResultSet rs = stmt.executeQuery("SELECT account_no, password FROM pass WHERE password ='password' && account_no='acc_no' ");
    while(rs.next())
    int account=rs.getInt(1);
              String passw=rs.getString(2);
    if(rs!=null)
    rs.close();
    if(stmt!=null)
    stmt.close();
    if(con!=null)
    con.close();
    %>
    <h2>Accountno:<%= account %></h2>
    <h2>Password:<%= passw %></h2>
    </BODY>
    </HTML>
    i am getting this error:
    org.apache.jasper.JasperException: Unable to compile class for JSP
    No Java compiler was found to compile the generated source for the JSP.
    This can usually be solved by copying manually $JAVA_HOME/lib/tools.jar from the JDK
    to the common/lib directory of the Tomcat server, followed by a Tomcat restart.
    If using an alternate Java compiler, please check its installation and access path.
    org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:128)
    org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:348)
    org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:415)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:455)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:555)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:300)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:293)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:240)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    but i already set up the java compiler though i m getting this error. please help me.

    You say you have set up the environment variables, but it is not working. You may have them set to the wrong thing. One common mistake is to point JAVA_HOME at the java/bin directory rather than just the /java directory.
    Another set of eyes finds small mistakes in the variables that you might not spot yourself.
    So please, post:
    The values of these environment variables
    The path to where the products are installed on your system (ie is it c:\java or c:\j2se1_4_2 or c:\program files?
    I would take another close look at that JAVA_HOME variable to make sure of it :-)
    Good luck,
    evnafets

  • Problems with jsp and jdbc

    I am writing a simple class to start learning about jdbc. I wrote the following WHICH COMPILES:
    public MyClass {
    System.out.println("establishing connection...");
    OracleConnectionPoolDataSource ods = new OracleConnectionPoolDataSource();
    // this is where all the variables are initialised.
    ods.setDriverType ("oci8");
    ods.setServerName ("test");
    ods.setNetworkProtocol ("tcp");
    ods.setDatabaseName ("tester");
    ods.setPortNumber (1521);
    ods.setUser ("test");
    ods.setPassword ("password");
    // this is the variable that will get the connection pool.
    // from this connection pool, you will get all ur connections.
    pool = new OracleConnectionCacheImpl(ods);
    and i am calling it by:
    System.out.println("connecting to DataBase");
    dbc = new MyClass();
    System.out.println("connected to DataBase");
    THIS WORKS FINE when i do either a command line execution - run a query thru a normal main method.
    HOWEVER, when i try and call it from a jsp page, i get the following error from tomcat:
    org.apache.jasper.JasperException: oracle/jdbc/pool/OracleDataSource
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:248)
    furthermore, the first system.out.println("establishing connection"); is not printed. "Connecting to Database" is printed however. i am really confused.
    however, i have an ancient copy of tomcat 3.2 that i used - just to test - and that worked fine. i have to get this to work with tomcat 4.1.
    i am really in a jam - any insights, please help!!!
    thankyou so much.

    Mahesh,
    It is the problem of your DRIVER not being in the classpath of TOMCAT. Put the driver in the lib folder of tomcat or else include the folder which contains the driver to the tomcat classpath. It should work OK.
    Good Luck.
    Sekar

  • New Bie - Starting with JSP and Servlets

    Hello fellow members,
    It's my pleasure to be a part of such a wonderful forum. Today, I am here to learn JSP, Servlets, and related tech/frameworks.
    I'd be thankful to any member who can guide me in the right direction.
    I have good working knowledge of Core java.
    I have a licensed copy of weblogic 9.2, though I have no idea how it works :).
    Looking forward for some good pointers to start with. If anyone can hand hold me and tell me exercises I should do every day, there is nothing like that. I can dedicate in excess of 6 hrs daily to learn these new technologies.
    Thanks in advance,

    Sonia_31 wrote:
    I planned to start with tomcat. Tomcat is a good choice.
    I am using my cousins laptop which already has BEA weblogic 9.2 installed. He used to work as software engineer. So I thought it was better start with weblogic, than going for something else.Apparently his company is using Weblogic.
    As I am serious about the whole thing weblogic is a better option. You have application servers and application servers. When I say that Weblogic is commonly only used in "real" production environments, I do not mean that "real" production environments only use Weblogic. You can use any self-respected application server to your taste. Either freeware or payware. That you're using a payware one to start with just made my eyebrows raise.
    Looking for some info to get started. I have downloaded the pdf you have mentioned and started studying. I'll post my questions soon.Good luck.

  • Delete data dynamically with JSP and servlet (Very Urgent)

    Hi,
    I am new with servlets and JSP. On my jsp page I am populating customer names in a drop box from database and I have 3 buttons ADD, DELETE and EDIT.
    Now when I press DELETE buttong I am calling delete function which is writen in Javascript on my jsp file only,now I want to pass these selcted values ehich I have stored in an array to be pass to servlet,so I can write Delete query for it and delete.
    Could anyone help with sample code>
    Here what I am trying to say:
    <HTML>
    <HEAD>
    <script language="JavaScript" type="text/javascript">
    <!--
    function remove()
    var u = confirm("Are you sure you want to Delete Selected names?")
    if (u==true)
         var selectedArray = new Array();
         var selObj = document.getElementById('CUSTOMER_NAME');
         var i;
         var count = 0;
         for (i=0; i<selObj.options.length; i++) {
         if (selObj.options.selected) {
         selectedArray[count] = selObj.options[i].value;
         count++;
         alert("names to be deleted are:"+selectedArray);
         // selectedArray has the selected items stored
         alert("Items Deleted!")
    else
    alert("No data were deleted!!You pressed Cancel!")
    //-->
    </script>
    </HEAD>
    <BODY>
    //calling servlet on action tag of form
    <FORM METHOD= 'POST' ACTION='Remove_Customer'>
    <form ><INPUT TYPE='submit' NAME='DELETE' VALUE='DELETE' onclick="remove()"></TD></form>
    <form><INPUT TYPE='submit' NAME='MODIFY' VALUE='MODIFY' onclick="modification()" ></TD></form>
    </BODY>
    </HTML>
    PLEASE HELPME,it's very urgent.
    Since the selected Array is in javascrip language , I don't know how can I pass that to servlet.
    request.getParameter is not working,since it's an array
    Many thanks in Advance.

    Hey,
    I am having problem deleting multiple values.
    If I just select one value,it deletes it
    But for multiple values the code is not working right.
    If there 2 values selcted then the last value gets deleted,if there are more than 2 values selected none values delete.
    Could plese check the code,and let meknow what mistake am I doing?
    Please help
    String delName="";
    int pos = tStr.indexOf(",");
    System.out.println(pos);
         if (pos != -1)
                   delName = tStr.substring(0, tStr.indexOf(","));
              tStr = tStr.substring(tStr.indexOf(",") + 1 );
                   System.out.println("DElName:"+delName);
                   System.out.println("tStr::"+tStr);                              
                        delName = tStr;
                        delete_Customer(delName);
    Thanks
    ASH

  • Problem with jsp and controller

    <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%>
    <%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt"%>
    <%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
    <%@ page import='com.uk.nhs.training.data.ActivityMatrix'%>
    <SCRIPT language="JavaScript" type="text/javascript">
    function bookActivity()
    if (document.bookActivityController.activitySelect.selectedIndex == 0)
    alert("Please Select Activity");
    else if (document.bookActivityController.trainerId.selectedIndex == 0)
    alert ( "Please Select Trainer");
    else if(document.bookActivityController.fromDate.value=="")
    alert("Please supply the Start Date of Activity")
    else
    validateForExistingCourses();
    function validateForExistingCourses()
    flag="wait";
    var trainerId=document.getElementById("trainerId").value;
    var fromDate=document.getElementById("fromDate").value;
    var toDate=document.getElementById("toDate").value;
    var activityId=document.getElementById("activitySelect").value;
    url="ajaxList.htm?actionType=checkBookedCoursesActivities&trainerId="+trainerId+"&fromDate="+fromDate+"&toDate="+toDate+"&activitySelect="+activityId;
    what = "checkForPreBookedCoursesActivities(req.responseXML)";
    doCallback(null);
    function checkForPreBookedCoursesActivities(theXmlResponse)
    // alert("in here in checking prebookedCourses");
    if(theXmlResponse != null)
         var isActivityExisting = theXmlResponse.getElementsByTagName('existingActivity')[0].text;
         var isCourseExisting = theXmlResponse.getElementsByTagName('existingbookedcourse')[0].text;     
              if(isActivityExisting=="Y")
              alert("Activity You are trying to book for Trainer already exists");
              return false;
              else if(isCourseExisting=="Y")
              if(confirm('Conflict Message. The dates choosen conflict with a current booking. Do you want to override'))
    window.open("/training1.1/secure/prebookedEvents.htm","clientwindow",'StatusBar', 'toolbar=yes,resizable=yes,scrollbars=yes,width=500,height=400,left=0,top=0');
    return false;
    else
    document.bookActivityController.action="/training1.1/secure/bookActivityTrainer.htm?actionType=submitForm";
    document.bookActivityController.submit();
    function goHomePage()
         window.location="/training1.1/secure/welcome.htm";
    function showHideAmPm(divId)
    if(document.bookActivityController.halfday.checked==true)
    showDiv(divId);
    else
    hideDiv(divId);
    function showDiv(divId)
    var item = document.getElementById(divId);
    alert("show item"+item);
    if (item)
    item.className='unhidden';
    function hideDiv(divId)
    var item = document.getElementById(divId);
    alert("unhide item"+item);
    if (item)
    item.className='hidden';
    function getActivitiesPm()
    if(document.bookActivityController.am.checked==true)
    document.bookActivityController.pm.checked=false;
    flag="wait";
         url="ajaxList.htm?actionType=activities&keyword=PM";
         what = "setActivities(req.responseXML)";
         doCallback(null);
         document.bookActivityController.activityTimeSelect.value="halfday";
         document.bookActivityController.activityTimeSubType.value="pm";
         // alert("subType"+document.bookActivityController.activityTimeSubType.value);
    function getActivitiesAm()
    if(document.bookActivityController.pm.checked==true)
    document.bookActivityController.am.checked=false;
    flag="wait";
         url="ajaxList.htm?actionType=activities&keyword=AM";
         what = "setActivities(req.responseXML)";
         doCallback(null);
         document.bookActivityController.activityTimeSelect.value="halfday";
         document.bookActivityController.activityTimeSubType.value="pm";
    function getSingleDayActivities()
    if(document.bookActivityController.singleday.checked==true)
    document.bookActivityController.moredays.checked=false;
    document.bookActivityController.halfday.checked=false;
    hideDiv('partofhalfday');
    document.bookActivityController.activityTimeSelect.value="fullday";
    flag="wait";
         url="ajaxList.htm?actionType=activities&keyword=FullDay";
         what = "setActivities(req.responseXML)";
         doCallback(null);
    else
    hideDiv('activitySelect');
    function getMoreDaysActivities()
    alert();
    if(document.bookActivityController.moredays.checked==true)
    document.bookActivityController.singleday.checked=false;
    document.bookActivityController.halfday.checked=false;
    hideDiv('partofhalfday');
    document.bookActivityController.activityTimeSelect.value="moredays";
    flag="wait";
         url="ajaxList.htm?actionType=activities&keyword=FullDay";
         what = "setActivities(req.responseXML)";
         doCallback(null);
    else
    hideDiv('activitySelect');
    showDiv('dateTo');
    function setActivities(theXmlResponse)
              //start filling the Venues Select boxes now
              if(theXmlResponse != null)
                   var coursesBox=document.getElementById("activitySelect");
                   coursesBox.options.length=0;
                   var activityElementsLength=theXmlResponse.getElementsByTagName('activity').length;     
                   var activityElementsArray=theXmlResponse.getElementsByTagName('activity');
                   //alert("length"+activityElementsLength+activityElementsArray);                              
              for(x = 0; x < activityElementsLength; x++)
                        //coursesBox.options[coursesBox.options.length] = new Option(coursesElementsArray[x].firstChild.text, coursesElementsArray[x].lastChild.text);
                        var optn = document.createElement("OPTION");
                   optn.text = activityElementsArray[x].firstChild.text;
    optn.value = activityElementsArray[x].lastChild.text;
    coursesBox.options.add(optn);
         if (activityElementsLength>0)
                   showDiv('activityTD');
              flag="release";
    </script>
    <div id="content"><!-- Top story -->
    <div id="topstory" class="box">
    <div id="topstory-img"></div>
    <!-- /topstory-img -->
    <div id="topstory-desc">
    <div id="topstory-title"><strong>BOOK Activity</strong></div>
    <!-- /topstory-title -->
    <div id="topstory-desc-in"></div>
    <!-- /topstory-desc-in --></div>
    <!-- /topstory-desc --></div>
    <!-- /topstory -->
    <div id="bodycontent">
    <% int errorCount=0; %>          
              <spring:bind path="bookactivityevent.*">
              <c:forEach items="${status.errorMessages}" var="error">
                        <B><font color="red">Error: <c:out value="${error}"/></font><B/>
                        <% errorCount++; %>
              </c:forEach>
              </spring:bind>
    <form method="post" name="bookActivityController" action="<c:url value="/secure/bookActivityTrainer.htm"/>">
    <table align="right" width="50%" border=0>
    <input type="hidden" name="activityTimeSelect"/>
    <input type="hidden" name="activityTimeSubType"/>
    <tr>
    <td align="left">
    <INPUT TYPE="checkbox" NAME="halfday" onclick="showHideAmPm('partofhalfday')">Half Day    
    <div align="left "id="partofhalfday" class="hidden">
    <INPUT TYPE="RADIO" NAME="am" onClick="getActivitiesAm()" value="am">AM <INPUT TYPE="RADIO" NAME="pm" onClick="getActivitiesPm()">PM <BR>
    </div>
    </td>
    </tr>
    <tr><td><INPUT TYPE="checkbox" NAME="singleday" onClick="getSingleDayActivities()"> Single Day</td>
    </tr>
    <tr>
    <td><INPUT TYPE="checkbox" NAME="moredays" onClick="getMoreDaysActivities()"> More Days</td>
    </tr>
         <tr>
              <td align="left" id="activityTD">Activity :
              <c:set var="activityMap" value=${requestScope.activityMap}/>
         <c:choose>
                        <c:when test="${activityMap = null}"
         <spring:bind path="bookactivityevent.userSuppliedActivity.activity.activityId">
              <select name="activitySelect" id="activitySelect" size="1"
                   STYLE="width: 150px">
                   <option value="Choose Activity" default>Choose Activity</option>
              </select>
              </spring:bind>
              </c:when>
              <c:otherwise>      
              <spring:bind path="bookactivityevent.userSuppliedActivity.activity.activityId">
              <select name="activitySelect" id="activitySelect"
                   size="1" STYLE="width: 150px">
                   <option value="" default>Choose Activity</option>
                   <c:forEach var="activity" items="${activityMap}" varStatus="a">
                        <c:choose>
                             <c:when
                                  test="${(bookactivityevent !=null) && (bookactivityevent.userSuppliedActivity.activity.activityId == activity.activityId)}">
                                  <option value="<c:out value="${activity.activityId}"/>" selected><c:out
                                       value="${activity.activityId}" /></option>
                             </c:when>
                             <c:otherwise>
                             <option value="<c:out value="${activity.activityId}"/>"><c:out
                                       value="${activity.activity}"/>
                             </c:otherwise>
                        </c:choose>
                   </c:forEach>
              </select>
         </spring:bind>
         </c:otherwise>
         </c:choose>
         </td>
    </tr>
         <tr>
              <td align="left">Trainer:
              <spring:bind path="bookactivityevent.userSuppliedActivity.trainer.trainerId">
              <select name="trainerId" id="trainerId"
                   size="1" STYLE="width: 150px">
                   <option value="" default>Choose Trainer</option>
                   <c:forEach var="trainer" items="${trainers}" varStatus="a">
                        <c:choose>
                             <c:when
                                  test="${(bookactivityevent !=null) && (bookactivityevent.userSuppliedActivity.trainer.trainerId == trainer.trainerId)}">
                                  <option value="<c:out value="${trainer.trainerId}"/>" selected>
                                  <c:out value="${trainer.firstName}"/>&nbsp<c:out
                                       value="${trainer.surName}" /></option>
                             </c:when>
                             <c:otherwise>
                                  <option value="<c:out value="${trainer.trainerId}"/>"><c:out
                                       value="${trainer.firstName}"/>&nbsp<c:out
                                       value="${trainer.surName}" /></option>
                             </c:otherwise>
                        </c:choose>
                   </c:forEach>
              </select>
         </spring:bind>     
              </td>
         </tr>
         <tr>
              <td align="left" id="dateFrom">From Date
              <spring:bind path="bookactivityevent.userSuppliedActivity.dateFrom">
              <input type="text" name="dateFrom" value=""/>
              </spring:bind>
              <img
                   src="../design/cal.gif" width="16" height="16" border="0"
                   alt="Click Here to Pick up the date"></td>
         </tr>
         <tr>
              <td align="left" id="dateTo" class="hidden">To Date
              <spring:bind path="bookactivityevent.userSuppliedActivity.dateTo">
              <input type="text" name="dateTo" value=""/>
              </spring:bind>
              <img
                   src="../design/cal.gif" width="16" height="16" border="0"
                   alt="Click Here to Pick up the date"></td>
         </tr>
         <tr>
              <td align="left" colspan="2"><input type="submit" name="_target1" value="BookActivity"/></td>
                   <c:if test="${(bookactivityevent != null) && (not empty bookactivityevent.conflictBookings)}">
    <td align="left" colspan="2"><input type="submit" name="_target2" value="OverRideBookings"/></td>
    </c:if>
              <td align="left" colspan="2"><input type="button" name="Cancel"
                   value="Cancel" onClick="goHomePage();" /></td>
         </tr>
    </table>
    </form>
    </div>
    <hr class="noscreen"/>
    <div class="content-padding"></div>
    <script language="JavaScript">
         var cal1 = new calendar1(document.bookActivityController.elements['dateFrom']);
         cal1.year_scroll = true;
         cal1.time_comp = false;
    var cal2 = new calendar1(document.bookActivityController.elements['dateTo']);
         cal2.year_scroll = true;
         cal2.time_comp = false;
    </script></div>
    <!-- /content -->
    package com.uk.nhs.training.controller;
    import java.beans.PropertyEditorSupport;
    import java.text.ParseException;
    import java.text.SimpleDateFormat;
    import java.util.ArrayList;
    import java.util.Date;
    import java.util.HashMap;
    import java.util.List;
    import java.util.Map;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.swing.text.html.HTMLDocument;
    import org.apache.commons.logging.Log;
    import org.apache.commons.logging.LogFactory;
    import org.springframework.util.StringUtils;
    import org.springframework.validation.BindException;
    import org.springframework.validation.Errors;
    import org.springframework.validation.ValidationUtils;
    import org.springframework.web.bind.ServletRequestDataBinder;
    import org.springframework.web.servlet.ModelAndView;
    import org.springframework.web.servlet.mvc.AbstractWizardFormController;
    import org.springframework.web.servlet.view.RedirectView;
    import com.uk.nhs.training.contractUtility.ContractHtmlReader;
    import com.uk.nhs.training.data.Activity;
    import com.uk.nhs.training.data.ActivityMatrix;
    import com.uk.nhs.training.data.BookActivityEvent;
    import com.uk.nhs.training.data.Booking;
    import com.uk.nhs.training.data.BookingDetails;
    import com.uk.nhs.training.data.Client;
    import com.uk.nhs.training.data.Course;
    import com.uk.nhs.training.data.Trainer;
    import com.uk.nhs.training.data.Venue;
    import com.uk.nhs.training.data.ActivityTimeConstants;
    import com.uk.nhs.training.service.ActivityMatrixService;
    import com.uk.nhs.training.service.ActivityService;
    import com.uk.nhs.training.service.BookingDetailsService;
    import com.uk.nhs.training.service.BookingService;
    import com.uk.nhs.training.service.ClientService;
    import com.uk.nhs.training.service.CourseService;
    import com.uk.nhs.training.service.TrainersService;
    import com.uk.nhs.training.service.VenueService;
    public class BookActivityController extends AbstractWizardFormController {
         protected final Log logger = LogFactory.getLog(getClass());
         private BookingService bookingFacade;
         private BookingDetailsService bookingDetailsFacade;
         private CourseService courseFacade;
         private VenueService venueFacade;
         private ClientService clientFacade;
         private ActivityMatrixService activityMatrixFacade;
         private ActivityService activityFacade;
         private TrainersService trainersFacade;
         private SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
         public BookActivityController() {
              setCommandClass(BookActivityEvent.class);
         setCommandName("bookactivityevent");
         setBindOnNewForm(true);
         protected Object formBackingObject(HttpServletRequest request)
                   throws Exception {
              BookActivityEvent bookActivityEvent = new BookActivityEvent();
              ActivityMatrix activityMatrix = new ActivityMatrix();
              activityMatrix.setActivity(new Activity());
              activityMatrix.setTrainer(new Trainer());
              List<Booking> bookingList = new ArrayList<Booking>();
              bookActivityEvent.setUserSuppliedActivity(activityMatrix);
              bookActivityEvent.setConflictBookings(bookingList);
              return bookActivityEvent;
         public Map referenceData(HttpServletRequest request, Object command, Errors errors, int Page)
              List trainers = trainersFacade.loadTrainers();
         Map trainersActivitiesMap = new HashMap();
              trainersActivitiesMap.put("trainers", trainers);          
              return trainersActivitiesMap;
         protected ModelAndView processFinish(HttpServletRequest request,
                   HttpServletResponse response, Object command, BindException errors) {
              try {
                   ActivityMatrix activity = (ActivityMatrix) command;
                   activityMatrixFacade.saveActivityMatrix(activity);
                   logger.info("Activity is successfully saved for the trainer");
              } catch (Exception e) {
                   e.getClass();
                   e.printStackTrace();
              return new ModelAndView("bookSuccess");
         @Override
         protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
              dateFormat.setLenient(true);
              binder.registerCustomEditor(java.sql.Date.class, "dateFrom", new SqlDateEditor(true));
              binder.registerCustomEditor(java.sql.Date.class, "dateTo", new SqlDateEditor(false));
              binder.registerCustomEditor(java.sql.Date.class, null, new SqlDateEditor(true));
         protected ModelAndView handleInvalidSubmit(HttpServletRequest request,
                   HttpServletResponse response) throws Exception {
              return new ModelAndView("bookInvalidSubmit");
         @Override
         protected ModelAndView processCancel(HttpServletRequest request,
                   HttpServletResponse response, Object command, BindException errors)
                   throws Exception {
              return new ModelAndView(new RedirectView("welcome.htm"));
         @Override
         protected void onBindAndValidate(HttpServletRequest request,
                   Object command, BindException errors, int page) throws Exception {
              BookActivityEvent bookActivityEvent = (BookActivityEvent) command;
              System.out.println(" PAGE : " + page);
              try {
                   switch (page) {
                   case 0:
                        if (request.getParameter("_target1") != null) {
                             ActivityMatrix userActivityMatrix = bookActivityEvent.getUserSuppliedActivity();
                             buildActivityMatrix(request, bookActivityEvent);     
                             validateActivityMatrix(bookActivityEvent, errors);
                             if (errors.getErrorCount() == 0)
                                  Trainer trainer = (Trainer) trainersFacade.loadTrainersById(userActivityMatrix.getTrainer().getTrainerId());
                                  bookActivityEvent.getUserSuppliedActivity().setTrainer(trainer);
                                  Activity activity= (Activity) activityFacade.loadActivitiesById(userActivityMatrix.getActivity().getActivityId());
                                  bookActivityEvent.getUserSuppliedActivity().setActivity(activity);
                                  boolean activityExists = checkForExistingActivities(userActivityMatrix, errors);
                                  if(!activityExists)
                                  boolean bookingsExist =      checkForBookedCourses(request, bookActivityEvent, errors);
                                  if(bookingsExist)
                                       // inject an error code so that it can be used in GUI
                                       errors.rejectValue("dateFrom","invalid dates","Trainer has Bookings in conflict with the Supplied Activity Dates");
                                  else
                                       errors.rejectValue("dateFrom","Activity Dates supplied already exist");
                        break;
                   case 1:
                        if (request.getParameter("_target2") != null)
                             * Get the user supplied activitymatrix and try to get all the bookings which are in conflict for the trainer
                        List<Booking> conflictBookingsList = (List<Booking>)request.getSession().getAttribute("conflictBookingsList");
                        break;
                   default:
              } catch (Exception e) {
                   System.err.println("Exception :" + e.getMessage());
              super.onBindAndValidate(request, command, errors, page);
         * @param request
         * @param userActivity
         * @param bookActivityEvent TODO
         private ActivityMatrix buildActivityMatrix(HttpServletRequest request, BookActivityEvent bookActivityEvent) {
              ActivityMatrix userActivity = bookActivityEvent.getUserSuppliedActivity();
              userActivity.getTrainer().setTrainerId((String)(request.getParameter("trainerId")));
              userActivity.getActivity().setActivityId((String)(request.getParameter("activitySelect")));          
              String activityTime = (String)request.getParameter("activityTimeSelect");
              String activitySubType = (String)request.getParameter("activityTimeSubType");
              if("fullday".equals(activityTime))
                   userActivity.getActivity().setTime(ActivityTimeConstants.FULLDAY.toString());
              else if("moredays".equals(activityTime))
                   userActivity.getActivity().setTime(ActivityTimeConstants.MOREDAYS.toString());
              else if("halfday".equals(activityTime)&& "am".equals(activitySubType))
                   userActivity.getActivity().setTime(ActivityTimeConstants.AM.toString());               
              else if("halfday".equals(activityTime)&& "pm".equals(activitySubType))
                   userActivity.getActivity().setTime(ActivityTimeConstants.PM.toString());
              if(!("moredays".equals(activityTime)))
                   userActivity.setDateTo(bookActivityEvent.getDateFrom());
              userActivity.setDateFrom(bookActivityEvent.getDateFrom());
              bookActivityEvent.setUserSuppliedActivity(userActivity);
              return userActivity;
         * Create an empty Booking details for client and course...
         * @param booking
         private void setInitialBookingDetails(Booking booking, BindException errors) {
              if (booking.getBookingType().equals("Client-Based")) {
                   if (booking.getClient() == null
                             || booking.getClient().getClientId() == null) {
                        booking.setClient(new Client());
              } else if (booking.getBookingType().equals("Staff")) {
                   booking.setClient(null);
              if (booking.getBookingDetails() == null) {
                   List<BookingDetails> bkDetailsList = new ArrayList<BookingDetails>();
                   BookingDetails bkDetails = new BookingDetails();
                   bkDetails.setCourse(new Course());
                   bkDetailsList.add(bkDetails);
                   booking.setBookingDetails(bkDetailsList);
              } else {
                   List bkDetList = booking.getBookingDetails();
                   if (bkDetList.size() < 1
                             || (bkDetList.size() > 0 && !((bkDetList.get(0)) instanceof BookingDetails))) {
                        BookingDetails bkDetails = new BookingDetails();
                        bkDetails.setCourse(new Course());
                        bkDetList.add(0, bkDetails);
                        booking.setBookingDetails(bkDetList);
                   } else if (((BookingDetails) bkDetList.get(0)).getCourse() == null
                             || ((BookingDetails) bkDetList.get(0)).getCourse()
                                       .getCourseId() == null) {
                        ((BookingDetails) bkDetList.get(0)).setCourse(new Course());
         @Override
         protected void validatePage(Object command, Errors errors, int page,
                   boolean finish) {
              BookActivityEvent activityEvent = (BookActivityEvent) command;
              if (finish) {
              super.validatePage(command, errors, page);
         * Validate client
         * @param booking
         * @param err
         private boolean checkForExistingActivities(ActivityMatrix userSuppliedActivity, Errors err)
              boolean exist = false;          
              List<ActivityMatrix> trainerActivityMatrixList =      activityMatrixFacade.getActivityMatrixBetweenDateRange(userSuppliedActivity.getTrainer().getTrainerId(),
                        userSuppliedActivity.getDateFrom(), userSuppliedActivity.getDateTo());
              if(ActivityTimeConstants.MOREDAYS.equals(userSuppliedActivity.getActivity().getTime()))
                   //checkForDates(trainerActivityMatrixList,);
              else if(ActivityTimeConstants.FULLDAY.equals(userSuppliedActivity.getActivity().getTime()))
                   // checkForDates(trainerActivityMatrixList,);
              else if(ActivityTimeConstants.AM.equals(userSuppliedActivity.getActivity().getTime()) ||
                        ActivityTimeConstants.PM.equals(userSuppliedActivity.getActivity().getTime()))
                   // checkForDates(trainerActivityMatrixList,);
         return exist;          
              * Check for existing bookings for a trainer and sets them on event object
              * @param request request.
              * @param event event.
              * @param err err.
              * @return true- bookings exist else false.
    private boolean checkForBookedCourses(HttpServletRequest request, BookActivityEvent event, Errors err)
         List<Booking> conflictBookingsList =      bookingFacade.loadBookingsByTrainerIdDateRange(event.getUserSuppliedActivity().getTrainer().getTrainerId(),
                   event.getUserSuppliedActivity().getDateFrom(),
                   event.getUserSuppliedActivity().getDateTo());
    request.getSession().setAttribute("conflictBookingsList",conflictBookingsList);     
                   if(conflictBookingsList!=null && conflictBookingsList.size()!=0)
                   event.setConflictBookings(conflictBookingsList);
                   return true;
                   else
                        return false;
         * Validate client
         * @param booking
         * @param err
         private void validateActivityMatrix(final BookActivityEvent activity, Errors err) {
    //          ValidationUtils.rejectIfEmptyOrWhitespace(err, "trainer.trainerId",
    //                    "required.trainer.trainerId", "Valid trainer needs to be selected.");
    ////          ValidationUtils.rejectIfEmptyOrWhitespace(err, "activity.activityId",
    ////                    "required.activity.activityId", "Valid activity needs to be selected.");
    //          if (err.getErrorCount() < 1)
    //                    if (activity.getDateFrom() == null) {
    //                         err.rejectValue("dateFrom", "required.dateFrom",
    //                                   "Valid Activity Start Date is required");
    //                    try
    //                         if (activity.getDateFrom() != null && activity.getDateTo() != null
    //                                   && (activity.getDateTo().before(activity.getDateFrom())))
    //                              err.rejectValue("dateTo", "required.dateTo",
    //                                        "Activity End Date Should be after start date.");
    //                    } catch (Exception ex) {
    //                         err.rejectValue("dateFrom",
    //                                   "dateFrom",
    //                                   "Improper dates, please provide valid dates.");
         * Validate Trainer
         * @param booking
         * @param e
         private void validateTrainer(final Booking booking, Errors e) {
              ValidationUtils.rejectIfEmptyOrWhitespace(e,
                        "bookingDetails[0].startDate",
                        "required.bookingDetails[0].startDate",
                        "Valid Booking Details startDate required.");
              ValidationUtils.rejectIfEmptyOrWhitespace(e,
                        "bookingDetails[0].trainer.trainerId",
                        "required.bookingDetails[0].trainer.trainerId",
                        "Valid Booking Details Trainer required.");
              if (e.getErrorCount() < 1)
                   for (BookingDetails bd : booking.getBookingDetails()) {
                        if (bd.getStartDate() == null) {
                             e.rejectValue("startDate", "required.bbb0",
                                       "Valid Booking details Start Date is required");
                        try {
                             if (bd.getStartDate() != null && bd.getEndDate() != null
                                       && (bd.getEndDate().before(bd.getStartDate())))
                                  e.rejectValue("endDate", "required.bbb0",
                                            "End Date Should be after starting date.");
                        } catch (Exception ex) {
                             e.rejectValue("bookingDetails[0].startDate",
                                       "before.bookingDetails[0].startDate",
                                       "Improper dates, please provide valid dates.");
                        if (bd.getTrainer() != null) {
                             e.rejectValue("trianerId", "required.trianerId",
                                       "Valid Trainer details required.");
         public BookingService getBookingFacade() {
              return bookingFacade;
         public void setBookingFacade(BookingService bookingFacade) {
              this.bookingFacade = bookingFacade;
         public CourseService getCourseFacade() {
              return courseFacade;
         public void setCourseFacade(CourseService courseFacade) {
              this.courseFacade = courseFacade;
         public VenueService getVenueFacade() {
              return venueFacade;
         public void setVenueFacade(VenueService venueFacade) {
              this.venueFacade = venueFacade;
         public ClientService getClientFacade() {
              return clientFacade;
         public void setClientFacade(ClientService clientFacade) {
              this.clientFacade = clientFacade;
         public TrainersService getTrainersFacade() {
              return trainersFacade;
         public void setTrainersFacade(TrainersService trainersFacade) {
              this.trainersFacade = trainersFacade;
         * getter method for activityFacade.
         * @return Returns the activityFacade.
         public ActivityService getActivityFacade() {
              return activityFacade;
         * setter method for activityFacade.
         * @param activityFacade The activityFacade to set.
         public void setActivityFacade(ActivityService activityFacade) {
              this.activityFacade = activityFacade;
         * getter method for activityMatrixFacade.
         * @return Returns the activityMatrixFacade.
         public ActivityMatrixService getActivityMatrixFacade() {
              return activityMatrixFacade;
         * setter method for activityMatrixFacade.
         * @param activityMatrixFacade The activityMatrixFacade to set.
         public void setActivityMatrixFacade(ActivityMatrixService activityMatrixFacade) {
              this.activityMatrixFacade = activityMatrixFacade;
         * getter method for bookingDetailsFacade.
         * @return Returns the bookingDetailsFacade.
         public BookingDetailsService getBookingDetailsFacade() {
              return bookingDetailsFacade;
         * setter method for bookingDetailsFacade.
         * @param bookingDetailsFacade The bookingDetailsFacade to set.
         public void setBookingDetailsFacade(BookingDetailsService bookingDetailsFacade) {
              this.bookingDetailsFacade = bookingDetailsFacade;
         class SqlDateEditor extends PropertyEditorSupport {
              private boolean isRequired = false;
              SqlDateEditor(boolean isRequired) {
                   this.isRequired = isRequired;
              public void setAsText(String text) throws IllegalArgumentException {
                   java.util.Date d = null;
                   if (!this.isRequired && !StringUtils.hasText(text)) {
                        setValue(null);
                   else
                        try {
                             d = dateFormat.parse(text);
                             setValue(new java.sql.Date(d.getTime()));
                        } catch (ParseException ex) {
                             throw new IllegalArgumentException("Could not parse date: " + ex.getMessage());
              public String getAsText() {
                   Date value = (java.sql.Date)getValue();
                   if (value != null) {
                        java.util.Date d = new java.util.Date(value.getTime());
                        return dateFormat.fo

    This topic is hopeless. Too much unnecessary code. Unformatted code. No question. No requirements. No step-by-step explanation how to reproduce problem. No expectations. No unexpectations/errors.
    Please read this how to get better help.

  • Problems with EJB and Servlet

    I'm doing a simple servlet that invokes an EJB taht returns an ArrayList with a values.
    My problem is that I do trace of my execution an this woks well in the EJB but when my remothe method do the return the app finish and never return to servlet that invoked it. I don't know 'cause this happend.
    I'm using WASD 5.0.1 as my Web y EJB container.
    Help would be appreciate

    What does that ArrayList contain?
    Could you post the code please.

  • Help with JSP and Servlets

    Hi,
    How would I create an editable JSP form from JDBC?
    I know how to retrieve the data from JDBC, but I'm still trying to figure out how to take that table data and format it into a tabluar format that user can make changes to it.
    Thanks,
    Tom
    Message was edited by:
    bztom_33
    Message was edited by:
    bztom_33

    CreateConnection();
    logger.info("Database connection opened in Testimonials");
    String queryText = "LOCK TABLE testimonials WRITE,posting_table WRITE";
    int numOfRows = st.executeUpdate(queryText);
    rs = st.executeQuery(SELECT_QUERY_FROM_TESTIMONIALS);
    logger.info("Query executed postingVeiw");
    String queryText1 = "UNLOCK TABLES";
    int numOfRow = st.executeUpdate(queryText1);
    while(rs.next())
    ClientData client = new ClientData();
    client.setName(rs.getString("name"));
    client.setTestimonial(rs.getString("testimonial"));
    client.setCompany(rs.getString("company"));
    clientList.add(client);
    RequestDispatcher disp = null;
    req.setAttribute("clientlist", clientList);
    String error1 = req.getParameter("");
    disp = req.getRequestDispatcher("testimonial.jsp");
    disp.forward(req,res);
    And call this arraylist from the jsp page
    Cheers
    Varun Rathore

  • Help with JSP and logic:iterate

    I have some queries hope someone can help me.
    I have a jsp page call request.jsp:
    ====================================
    <%@ page import="java.util.*" %>
    <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
    <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
    <html>
    <body>
       <%@ page import="RequestData" %>
       <jsp:useBean id="RD" class="RequestData" />
       <%Iterator data = (Iterator)request.getAttribute("Data");%>
       <logic:iterate id="element" name="RD" collection="<%=data%>">
          <jsp:getProperty name="RD" property="requestID" />
          <%=element%><br>
       </logic:iterate>
    </body>
    </html>
    And I have the RequestData.java file:
    ======================================
    private int requestID = 1234;
    public int getRequestID() { return requestID; }
    The jsp page display:
    ======================
    0 RequestData@590510
    0 RequestData@5b6d00
    0 RequestData@514f7f
    0 RequestData@3a5a9c
    0 RequestData@12d7ae
    0 RequestData@e1666
    Seems like the requestID is not returned. Does anybody know this?
    I have done the exact one using JSP and servlets, trying to learn using JSP and custom tags. The one with JSP and servlet looks like:
    ============================================
    <%@ page import="RequestData" %>
    <%Iterator data = (Iterator)request.getAttribute("Data");
    while (data.hasNext()) {
       RequestData RD = (RequestData)data.next();
       out.println(RD.getRequestID() );
    }%>

    Oh think I got it...
    but one thing I'm not sure is...
    If I use "<jsp:useBean id="RD" class="RequestData" />", do I still need "<%@ page import="RequestData" %>"?
    I tried without and it gives me error...

Maybe you are looking for