ajaxjspservletsjbossajaxtags

Jsp ajax tag not working in jsp.. Unable to load tag handler class exception


Iam new to Ajax tags.. Whenever I try to execute these, HTML part works as expected. But Ajax tags not working..

Getting unable to load tag handler class exception "org.ajaxtags.tags.AjaxSelectTag"..

<%@ taglib uri="/WEB-INF/ajaxtld/ajaxtags.tld" prefix="ajax" %>

 <html>
   <head>
     <title>AJAX JSP Tag Library</title>



    <script type="text/javascript" src="js/prototype-1.6.0.3.js"></script>
    <script type="text/javascript" src="js/scriptaculous/scriptaculous.js"></script>
    <script type="text/javascript" src="js/overlibmws/overlibmws.js"></script>
    <script type="text/javascript" src="js/ajaxtags-1.2-beta1.js"></script>



    <link type="text/css" rel="stylesheet" href="/WEB-INF/css/ajaxtags.css" />
    <link type="text/css" rel="stylesheet" href="/WEB-INF/css/displaytag.css" />
</head>
<body>

    <form>



        Make:
        <select id = "make" name = "make">
            <option value="">Select make</option>
            <c:forEach items="${makes}" var="make">
                <option value="${make}">${make}</option>
            </c:forEach>
        </select>

        Model:
        <select id="model" name="model" >
            <option value="">Select model</option>
        </select>

        <input type="button" value="read">




        <div id="tar"></div>


    </form>

    <ajax:select baseUrl="$Sample/samplejava" source="make" target="model"   parameters="make={make}" />

</body>
</html>

servlet part is defined below..

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class samplejava extends HttpServlet {

protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    PrintWriter out = response.getWriter();
    try {
        /* TODO output your page here. You may use following sample code. */
        out.println("<!DOCTYPE html>");
        out.println("<html>");
        out.println("<head>");
        out.println("<title>Servlet samplejava</title>");
        out.println("</head>");
        out.println("<body>");
        out.println("<h1>Servlet samplejava at " + request.getContextPath() + "</h1>");
        out.println("Here is the response...");
        out.println("</body>");
        out.println("</html>");
    } finally {
        out.close();
    }
}

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    processRequest(request, response);

    try {

        String res = request.getParameter("make");
        RequestDispatcher rd = request.getRequestDispatcher("index.jsp");
        PrintWriter out = response.getWriter();
        out.println(res);
        response.getWriter().write("hai!! this is response...");
        response.sendRedirect("success.jsp");
    } catch (Exception e) {
        response.sendRedirect("error.jsp");
    }
}

@Override
public String getServletInfo() {
    return "Short description";
}// </editor-fold>

}

Anybody can suggest please...


Solution

  • Its working fine, when I just change doGet() method to doPost() method..

        import java.io.IOException;
        import java.io.PrintWriter;
        import javax.servlet.RequestDispatcher;
        import javax.servlet.ServletException;
        import javax.servlet.http.HttpServlet;
        import javax.servlet.http.HttpServletRequest;
        import javax.servlet.http.HttpServletResponse;
    
        public class samplejava extends HttpServlet {
    
        protected void processRequest(HttpServletRequest request, 
        HttpServletResponse response)throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        try {
        /* TODO output your page here. You may use following sample code. */
        out.println("<!DOCTYPE html>");
        out.println("<html>");
        out.println("<head>");
        out.println("<title>Servlet samplejava</title>");
        out.println("</head>");
        out.println("<body>");
        out.println("<h1>Servlet samplejava at " + request.getContextPath() + "</h1>");
        out.println("Here is the response...");
        out.println("</body>");
        out.println("</html>");
       } finally {
        out.close();
       }
        }
    
       @Override
        protected void doPost(HttpServletRequest request, HttpServletResponse response)//I just changed the doGet() to doPost(), its working fine
        throws ServletException, IOException {
          processRequest(request, response);
    
          try {
    
         String res = request.getParameter("make");
        RequestDispatcher rd = request.getRequestDispatcher("index.jsp");
        PrintWriter out = response.getWriter();
        out.println(res);
        response.getWriter().write("hai!! this is response...");
        response.sendRedirect("success.jsp");
       } catch (Exception e) {
        response.sendRedirect("error.jsp");
       }
       }
    
        @Override
     public String getServletInfo() {
        return "Short description";
       }// </editor-fold>
    
          }