AjaxServlets

I have a problem with the usage ajax on the page.
This is a class overwrites method doPost.
public class TemplateAjaxServlet extends HttpServlet {
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
request.setCharacterEncoding("UTF-8");
String name = request.getParameter("name");
String load = request.getParameter("load");
response.setContentType("text/xml");
response.setCharacterEncoding("UTF-8");
response.setHeader("Cache-Control", "no-cache");
String answer = "<save>";
if ("true".equals(load)) {
answer += "true</save>";
response.getWriter().write(answer);
response.setStatus(200);
return;
} else {
answer += "false</save>";
response.getWriter().write(answer);
response.setStatus(200);
This is javascript.
function fill() {
var name = document.getElementById("FORM:TEMPLATE_NAME").value;
var load = document.getElementById("FORM:SAVE_TEMPLATE").checked;
var req = initRequest();
req.onreadystatechange = function() {
if (req.readyState == 4) { /* Request processing complete */
if (req.status == 200) { /* http: success */
var url = contextPath + "/templateAjaxServlet";
req.open("POST", url, true);
req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
var params = 'name=' + name + "&load=" + load;
req.send(params);
This js returns error on line 7 - Error: [Exception... "Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsIXMLHttpRequest.status]" nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)" location: "JS frame :: https://localhost/***.jsf :: anonymous :: line 471" data: no]
It means that req.status have not been initialized.
What I have to do to repair this error?

use code tags when posting code

Similar Messages

  • Call struts action from javascript?

    Hi all
    I'm having problem already discussed here quite a lot, but I have idea to solve it different way. And need to know is it possible or I'm doing mission impossible here :(
    I have JSP with 2 drop down lilsts, where the second is populated according to selected value from first - that's basically my problem.
    Is it possible to somehow only call my struts action which will return all needed values using javascript and onchange event handler?
    I dont have any experience with javascript, and I'm trying to avoid it as much as possible at the moment.
    Thanks in advance

    well as far your requirement is concern if at all you are planning to implement AJAX try to use the below link which might be of some help...
    http://www.it-eye.nl/weblog/2005/12/13/ajax-in-struts-implementing-dependend-select-boxes/
    However,I somehow feel there are few loopholes in the author's approach...
    i advice to use XmlHttpRequest.reponseXML property there.
    However, i've mentioned a sample code snippet for you reference.
    XML Response Pattern :
    ======================
    <? xml version="1.1" ?>
    <dropdown>
    <option>
    <val>CUSTOMIZED_VALUE</val>
    <text>CUSTOMIZED_VALUE</text>
    </option>
    </dropdown>Sample.jsp:
    ===========
    <%@page language="java" %>
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>Automatic Drop-Down Updation</title>
         <script language="javascript">
          // Global Variable for XmlHttp Request Object  
          var xmlhttp
          // Timer Variables
          var c = 0
          var t
           /* A function which calls a servlet  named AjaxServlet to get XmlData using XmlHttpObject */    
            function refreshCombo(txt){
                xmlhttp = null
                // code for initializing XmlHttpRequest Object On Browsers like  Mozilla, etc.
                if (window.XMLHttpRequest){
                     xmlhttp = new XMLHttpRequest()
                // code for initializing XmlHttpRequest Object On Browsers like IE
               else if (window.ActiveXObject) {
                   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP")
               if (xmlhttp != null){
                  // Setting the Action url to get XmlData
                   url = "dropdown.do?count="+txt;
                   // Course of Action That Should be Made if their is a change in XmlHttpRequest Object ReadyState NOTE : it is 4 when it has got request from CGI
                   xmlhttp.onreadystatechange = getResponseAction;
                   // Open the Request by passing Type of Request & CGI URL
                   xmlhttp.open("GET",url,true);
                   // Sending URL Encoded Data
                   xmlhttp.send(null);
               else{
                 // Only Broswers like IE 5.0,Mozilla & all other browser which support XML data Supports AJAX Technology
                 // In the Below case it looks as if the browser is not compatiable
                  alert("Your browser does not support XMLHTTP.")
          /* Used for verifing right ReadyState & Status of XmlHttpRequest Object returns true if it is verified */
          function verifyReadyState(obj){
             // As Said above if XmlHttp.ReadyState == 4 then the Page Has got Response from WebServer
              if(obj.readyState == 4){
               // Similarly if XmlHttp.status == 200 it means that we have got a Valid response from the WebServer
                if(obj.status == 200){               
                    return true
                 else{
                    alert("Problem retrieving XML data")
          /* Action that has to take place after getting reponse */
          function getResponseAction(){
              // Verifying State & Status
              if(verifyReadyState(xmlhttp) == true){
                  // Building a DOM parser from Response Object
                  var response = xmlhttp.responseXML.documentElement
                  // Deleting all the Present Elements in the Drop-Down Box
                  drRemove()      
                  // Checking for the Root Node Tag
                  var x = response.getElementsByTagName("option")
                  var val
                  var tex
                  var optn
                  for(var i = 0;i < x.length; i++){
                     optn = document.createElement("OPTION")
                     var er
                     // Checking for the tag which holds the value of the Drop-Down combo element
                     val = x.getElementsByTagName("val")
    try{
    // Assigning the value to a Drop-Down Set Element
    optn.value = val[0].firstChild.data
    } catch(er){
    // Checking for the tag which holds the Text of the Drop-Down combo element
    tex = x[i].getElementsByTagName("text")
    try{
    // Assigning the Text to a Drop-Down Set Element
    optn.text = tex[0].firstChild.data
    } catch(er){
    // Adding the Set Element to the Drop-Down
    document.SampleForm.SampleCombo.options.add(optn)
    /* Function removes all the elements in the Drop-Down */
    function drRemove(){
    var x = document.SampleForm.SampleCombo
    for(var i = document.SampleForm.SampleCombo.length - 1 ; i >= 0 ; i--){                     
    x.remove(i)
    </script>
    </head>
    <body onload="syncCount()">
    <pre> <h1>Refresh Drop-Down <div id='txt'> </div> </h1></pre>
    <form name="SampleForm">
    <!-- Drop Down which has country list -->
    <select name="x" onchange="refreshCombo(this.value)">
                   <option value="1">United States</option>
                   <option value="2">United Kingdom</option>
                   <option value="3">United Arab Emriates</option>
    </select>
    <!-- Drop Down which is dependent on Country Drop down get list of states -->
    <select name="SampleCombo">
    <option value="-1">Pick One</option>
    </select>
    </form>
    </body>
    </html>
    struts-config.xml:
    ==================
    <action-mappings>
    <action path="/dropdown" type="com.controlleraction.AjaxActionClass">
    <forward name="error" path="/error.jsp"/>
    </action>
    </action-mappings>AjaxActionClass.java:
    =====================
    package com.controlleraction;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpSession;
    import org.apache.struts.action.ActionErrors;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;
    public class AjaxActionClass extends DispatchAction {
      public ActionForward execute( ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws Exception {
        String req = new String("");
        try{
           req = request.getParameter("count");
        } catch(Exception exp){
       if(!req.equals("")){
           response.setContentType("text/xml");        
           response.setHeader("Pragma","no-cache");
           response.setHeader("Cache-Control","no-cache,post-check=0,pre-check=0");
           PrintWriter out = response.getWriter();
           /*a sample bean where we trying to call a service from Model*/
           com.Biz.XmlBean xml = new XmlBean();
           String buffer = xml.getXmlData(req);
           if(xml.close() == true && buffer.equals("") == false)
             out.write(buffer);     
           return(null);
      } else {
         return new ActionForward("error");
    }XmlBean.java:
    =============
    * XmlBean.java
    import java.sql.*;
    import java.util.*;
    import java.io.*;
    * @author RaHuL
    public class XmlBean {
        private Connection con = null;
        private PreparedStatement pstmt = null;
        private ResultSet rs = null;
        // Setting CLASSURL path to TYPE I Driver
        private String CLASSURL = "sun.jdbc.odbc.JdbcOdbcDriver";
        /* Specifing CONNECTION PATH to a DSN named TestDsn
         * Please Make Sure you create a DSN Named TestDsn to your database which holds EMP table
        private String CONNECTIONURL = "jdbc:odbc:TestDsn";
        boolean IS_ESTABLISHED = false;
        /** Creates a new instance of XmlBean and also establishes DB Connections */
        public XmlBean() {
            try{
                Class.forName(CLASSURL);
                con = DriverManager.getConnection(CONNECTIONURL,"admin","");
                IS_ESTABLISHED = true;
            } catch(SQLException sqe){
                sqe.printStackTrace();
            } catch(Exception exp){
                exp.printStackTrace();
        /* Generates XmlData For the Business Logic Specified */
        public String getXmlData(String req){
            String XmlBuffer = new String("");
            if(IS_ESTABLISHED == true){
                try{
                    pstmt = con.prepareStatement("SELECT stateid,statename FROM STATE_TABLE where countryid = ?");
                    pstmt.setString(1,req);
                    rs = pstmt.executeQuery();
                    if(rs != null){
                        XmlBuffer = XmlBuffer + "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>";
                        XmlBuffer = XmlBuffer + "<!--  Edited by Rahul Sharma -->";
                        // Root Node
                        XmlBuffer = XmlBuffer + "<dropdown>";
                        while(rs.next()){
                            String value = rs.getString(1);
                            String text = rs.getString(2);
                            // Sub-root Node
                            XmlBuffer = XmlBuffer + "<option>";
                            // node which holds value of drop-down combo
                            XmlBuffer = XmlBuffer + "<val>"+value+"</val>";
                            // node which holds text for drop-down combo
                            XmlBuffer = XmlBuffer + "<text>"+text+"</text>";
                            XmlBuffer = XmlBuffer + "</option>";
                        XmlBuffer = XmlBuffer + "</dropdown>";
                }catch(SQLException sqe){
                    sqe.printStackTrace();
                } catch(Exception exp){
                    exp.printStackTrace();
            return(XmlBuffer);
        /* Closes the DB Connection Conmpletely */
        public  boolean close(){
            if(IS_ESTABLISHED == true){
                try{
                    pstmt.close();
                    con.close();
                    return(true);
                } catch(SQLException sqe){
                    sqe.printStackTrace();
                } catch(Exception exp){
                    exp.printStackTrace();
            return(false);
    NOTE: I understand i'm not completely coded things as per proper coding standards.please execuse me for that as this example was just given to enable user to learn how XmlHttpRquest,reponseXML
    can be used for better purposes instead of devising manual parsing.
    where i've used XmlHttpResponse pattern to be in XML. you may make use of other practices like JSON & so on depending on your requirement..
    and and if you are more instrested in integrating Struts with AJAX using few frameworks & customized tag based support please go though the below link.
    http://struts.sourceforge.net/ajaxtags/index.html
    Hope that might help :)
    REGARDS,
    RaHuL

  • Problem with woodstock dropdown

    hi all
    i'm using netbeans 7.5
    my jsp code is
    <jsp:root version="2.1" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:webuijsf="http://www.sun.com/webui/webuijsf">
    <jsp:directive.page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"/>
    <f:view>
    <webuijsf:page id="page1">
    <webuijsf:html id="html1">
    <webuijsf:head id="head1">
    <webuijsf:link id="link1" url="/resources/stylesheet.css"/>
    <script type="text/javascript">
    var req;
    var target;
    var isIE;
    function initRequeskt(url) {
    if (window.XMLHttpRequest) {
    req = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
    isIE = true;
    req = new ActiveXObject("Microsoft.XMLHTTP");
    function validateUserId() {
    var url = "AjaxServlet";
    // Invoke initRequest(url) to create XMLHttpRequest object
    initRequest(url);
    req.onreadystatechange = processRequest;
    req.open("GET", url, true);
    req.send(null);
    function processRequest() {
    if (req.readyState == 4) {
    if (req.status == 200) {
    // Extract "true" or "false" from the returned data from the server.
    // The req.responseXML should contain either <valid>true</valid> or <valid>false</valid>
    var message = req.responseXML.getElementsByTagName("number")[0].childNodes[0].nodeValue;
    // Call "setMessageUsingDOM(message)" function to display
    // "Valid User Id" or "Invalid User Id" message.
    setMessageUsingInline(message);
    // If the user entered value is not valid, do not allow the user to
    // click submit button.
    function setMessageUsingInline(message) {
    document.getElementById("form1:textField2").setProps( {value: message } );
    function showDropDownValue() {
    document.getElementById('form1:textField1').setProps( {value: document.getElementById('form1:dropDownCountry').getSelectedValue()} );
    document.getElementById('form1:dropDownCity').refresh('form1:textField1');
    validateUserId();
    function showCalendarValue() {
    document.getElementById('form1:textField2').setProps( {value: document.getElementById('form1:calendar1').getProps().value} );
    function showChackboxValue() {
    document.getElementById('form1:textField3').setProps( {value: document.getElementById('form1:checkbox1').getProps().checked} );
    </script>
    </webuijsf:head>
    <webuijsf:body id="body1" style="-rave-layout: grid">
    <webuijsf:form id="form1">
    <webuijsf:dropDown binding="#{Page1.dropDownCountry}" id="dropDownCountry" items="#{myobj.dropDownCountryValue}"
    onChange="showDropDownValue(); " style="left: 192px; top: 216px; position: absolute"/>
    <webuijsf:textField binding="#{Page1.textField1}" id="textField1" onClick="showDropDownValue()"
    style="left: 336px; top: 216px; position: absolute" text="#{myobj.country_name}" visible="false"/>
    <webuijsf:calendar binding="#{Page1.calendar1}" id="calendar1" onClick="showCalendarValue();" style="left: 144px; top: 288px; position: absolute"/>
    <webuijsf:textField binding="#{Page1.textField2}" id="textField2" style="left: 336px; top: 288px; position: absolute"/>
    <webuijsf:checkbox binding="#{Page1.checkbox1}" id="checkbox1" label="Checkbox" onClick="showChackboxValue()" style="position: absolute; left: 192px; top: 360px"/>
    <webuijsf:textField binding="#{Page1.textField3}" id="textField3" style="left: 336px; top: 360px; position: absolute"/>
    <webuijsf:dropDown binding="#{Page1.dropDownCity}" id="dropDownCity" items="#{myobj.dropDownCityValue}" style="position: absolute; left: 528px; top: 216px"/>
    </webuijsf:form>
    </webuijsf:body>
    </webuijsf:html>
    </webuijsf:page>
    </f:view>
    </jsp:root>
    face-config
    <managed-bean>
    <managed-bean-name>myobj</managed-bean-name>
    <managed-bean-class>newpack.NewClass</managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
    </managed-bean>
    dropDownCountry is name of countries
    dropDownCity is name of cities choosen by dropDownCountry
    when i change dropDownCountry, intseat of refreshing dropDownCity in dropDownCity in old cities too
    for example if i have choosen Italy in dropDownCountry then items of dropDownCity is rome, milan
    then if i switch dropDownCountry to England then items of dropDownCity must be london, liverpool
    and in my case when i switch from Italy to England items of dropDownCity is rome, milan, london, liverpool
    why dropDownCity items store old datas too
    anyone can help?

    martin.wainamoinen wrote:
    I noticed that the page gets reinstanciated on every refresh and everything gets reset, don't know if this is default behaviourThe managed bean is apparently request scoped. I think it's time to throw away the "visual editor" you're using or to switch to "source code" mode or so and start with writing code yourself. Do not do drag'n'drop, you would become code-blind and you would constantly fight with trivial and obvious problems at code/specification level.

  • Jsf 1.2_08 gives me blank page when i use h:panelGrid with binding attribut

    I am using jsf 1.2_08 (Mojarra 1.2_08-b06-FCS) + jstl-1.2.jar + Apache Tomcat/6.0.6 + jdk1.5.0_08 on linux suse server. when i load a jsp page with a h:panelGrid, i get a blank page
    my panelGrid is as follows
    <h:panelGrid id="financialProjections" binding="#{veusSituationMonitorDisplayBean.financialProjections}" border="0" cellpadding="0" cellspacing="0" columnClasses="nspLabel w200,ra bl,ra bl,ra bl,ra bl,ra bld,ra bl,ra bl" columns="8" width="100%"/>
    when i remove the binding attribute, rest of the page displays fine.
    Thanks in Advance
    my web.xml is
    <?xml version="1.0"?>
    <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd">
    <context-param>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>server</param-value>
    </context-param>
    <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet>
    <servlet-name>AJAXServlet</servlet-name>
    <servlet-class>net.em.servlets.AJAXServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet>
    <servlet-name>InitialLizeApplicationbeansServlet</servlet-name>
    <servlet-class>net.em.servlets.InitialLizeApplicationBeanServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.faces</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
    <servlet-name>AJAXServlet</servlet-name>
    <url-pattern>/abc.ajax</url-pattern>
    </servlet-mapping>
    <filter>
    <filter-name>ExtensionsFilter</filter-name>
    <filter-class>
    net.em.emrp.filters.EMExtensionsFilter
    </filter-class>
    <init-param>
    <param-name>uploadMaxFileSize</param-name>
    <param-value>10m</param-value>
    </init-param>
    <init-param>
    <param-name>uploadThresholdSize</param-name>
    <param-value>100k</param-value>
    </init-param>
    </filter>
    <filter>
    <filter-name>ResponseOverrideFilter</filter-name>
    <filter-class>org.displaytag.filter.ResponseOverrideFilter</filter-class>
    </filter>
    <session-config>
    <session-timeout>
    720 <!-- minutes -->
    </session-timeout>
    </session-config>
    <filter-mapping>
    <filter-name>ExtensionsFilter</filter-name>
    <servlet-name>Faces Servlet</servlet-name>
    </filter-mapping>
    <filter-mapping>
    <filter-name>ResponseOverrideFilter</filter-name>
    <url-pattern>*.do</url-pattern>
    </filter-mapping>
    <filter-mapping>
    <filter-name>ResponseOverrideFilter</filter-name>
    <url-pattern>*.jsp</url-pattern>
    </filter-mapping>
    <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
    <error-page>
    <error-code>404</error-code>
    <location>/error404.html</location>
    </error-page>
    <error-page>
    <error-code>500</error-code>
    <location>/error500.html</location>
    </error-page>
    <taglib>
    <taglib-uri>http://ajaxtags.org/tags/ajax</taglib-uri>
    <taglib-location>/WEB-INF/ajaxtags.tld</taglib-location>
    </taglib>
    </web-app>

    BalusC wrote:
    I rather mean that you shouldn't instantiate the HtmlPanelGrid in the bean yourself, but just use the instance which is set through the setter during the restore_view phase.BalusC, why do you recommend this? The spec allows for the bean to create the component:
    *JSF 1.2, section 3.1.5* says:
    When a component instance is first created (typically by virtue of being referenced by a UIComponentELTag in a JSP page), the JSF implementation will retrieve the ValueExpression for the name binding, and call getValue() on it. If this call returns a non-null UIComponent value (because the JavaBean programmatically instantiated and configured a component already), that instance will be added to the component tree that is being created. If the call returns null, a new component instance will be created, added to the component tree, and setValue() will be called on the ValueBinding (which will cause the property on the JavaBean to be set to the newly created component instance).

  • ZCC Login failed after Migration from 11.3.1 FRU1 to 11.3.2

    Hey,
    System: 6 Primary Server Sless 11 SP3
    LDAP: EDIR
    Primary: 11.3.2
    Sats: 11.3.1 FRU1
    After Migration from 11.3.1 FRU1 to 11.3.2
    i'll try to login in ZCC
    Message ZCC
    Error: Login Error: com.novell.zenworks.datamodel.exceptions.InternalD ataModelException: javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: Certificates does not conform to algorithm constraints
    See the ZENworks Control Center log file (zcc.log) for the full stack trace.
    I tryed with default admin and see that the USERSource is not reachable.
    I take a look in the configuration / usersource and there is an Error like: Unable to read contexts. One or more of your connections don't support non-SSL.
    ZCC.log sayed
    [javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: Certificates does not conform to algorithm constraints] [] [com.novell.zenworks.datamodel.exceptions.InternalD ataModelException] [ZENServer]
    [DEBUG] [12/30/2014 09:54:02.417] [3547] [ZENServer] [72] [zenworks] [ZCC] [] [Form.java CSRF TOKEN:d1b804076c63e7393af1a72442ced4b5 for the PageId:authoritativeSourceDetails] [] [] [] [ZENServer]
    [DEBUG] [12/30/2014 09:54:03.144] [3547] [ZENServer] [85] [zenworks] [ZCC] [] [QuickTask build tasks called in createChildControls, normal flow before ajax] [] [] [] [ZENServer]
    [DEBUG] [12/30/2014 09:54:03.348] [3547] [ZENServer] [69] [zenworks] [ZCC] [] [com.novell.zenworks.datamodel.exceptions.InternalD ataModelException: javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: Certificates does not conform to algorithm constraints
    at com.novell.zenworks.datamodel.services.Certificate ManagerImpl.getCertificates(CertificateManagerImpl .java:179)
    at com.novell.zenworks.datamodel.utils.ldap.LDAPUtil. validateCertificateExpiry(LDAPUtil.java:1162)
    at com.novell.zenworks.datamodel.utils.ldap.LDAPUtil. getLDAPConnectionInfo(LDAPUtil.java:774)
    at com.novell.zenworks.datamodel.utils.ldap.LDAPUtil. getLDAPConnectionInfo(LDAPUtil.java:559)
    at com.novell.zenworks.datamodel.utils.ldap.LDAPUtil. getLDAPConnectionInfo(LDAPUtil.java:386)
    at com.novell.zenworks.datamodel.utils.ldap.LDAPUtil. getLDAPConnectionInfo(LDAPUtil.java:359)
    at com.novell.zenworks.datamodel.utils.ldap.LDAPUtil. getLDAPConnectionInfo(LDAPUtil.java:325)
    at com.novell.zenworks.datamodel.utils.ldap.LDAPUtil. getLDAPConnectionInfo(LDAPUtil.java:311)
    at com.novell.zenworks.core.web.internal.UserSourceSt atusAJAX.getImageData(UserSourceStatusAJAX.java:77 )
    at com.novell.web.ajax.ImageAJAX.service(ImageAJAX.ja va:38)
    at com.novell.web.ajax.AJAXDataHandler.service(AJAXDa taHandler.java:40)
    at com.novell.web.AjaxServlet.serviceImpl(AjaxServlet .java:100)
    at com.novell.web.AjaxServlet.service(AjaxServlet.jav a:74)
    at com.novell.zenworks.fw.web.internal.ZENworksAjaxSe rvlet.service(ZENworksAjaxServlet.java:47)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:727)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:303)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:208)
    at com.patchlink.sapphire.web.pages.vulnerability.ses sion.HibernateSessionFilter.doFilter(HibernateSess ionFilter.java:75)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:208)
    at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:220)
    at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:122)
    at org.apache.catalina.authenticator.AuthenticatorBas e.invoke(AuthenticatorBase.java:501)
    at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:171)
    at com.googlecode.psiprobe.Tomcat70AgentValve.invoke( Tomcat70AgentValve.java:39)
    at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:103)
    at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:116)
    at com.novell.zenworks.tomcat.ZENRequestValve.invoke( ZENRequestValve.java:1346)
    at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:408)
    at org.apache.coyote.http11.AbstractHttp11Processor.p rocess(AbstractHttp11Processor.java:1070)
    at org.apache.coyote.AbstractProtocol$AbstractConnect ionHandler.process(AbstractProtocol.java:611)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProce ssor.run(JIoEndpoint.java:316)
    at java.util.concurrent.ThreadPoolExecutor.runWorker( ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:615)
    at org.apache.tomcat.util.threads.TaskThread$Wrapping Runnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:745)
    Caused by: javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: Certificates does not conform to algorithm constraints
    at sun.security.ssl.Alerts.getSSLException(Alerts.jav a:192)
    at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl .java:1884)
    at sun.security.ssl.Handshaker.fatalSE(Handshaker.jav a:276)
    at sun.security.ssl.Handshaker.fatalSE(Handshaker.jav a:270)
    at sun.security.ssl.ClientHandshaker.serverCertificat e(ClientHandshaker.java:1439)
    at sun.security.ssl.ClientHandshaker.processMessage(C lientHandshaker.java:209)
    at sun.security.ssl.Handshaker.processLoop(Handshaker .java:878)
    at sun.security.ssl.Handshaker.process_record(Handsha ker.java:814)
    at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocke tImpl.java:1016)
    at sun.security.ssl.SSLSocketImpl.performInitialHands hake(SSLSocketImpl.java:1312)
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLS ocketImpl.java:1339)
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLS ocketImpl.java:1323)
    at com.novell.zenworks.security.certificates.Certific ateUtility.getCertChain(CertificateUtility.java:12 1)
    at com.novell.zenworks.datamodel.services.Certificate ManagerImpl.getCertificates(CertificateManagerImpl .java:175)
    ... 35 more
    Caused by: java.security.cert.CertificateException: Certificates does not conform to algorithm constraints
    at sun.security.ssl.AbstractTrustManagerWrapper.check AlgorithmConstraints(SSLContextImpl.java:946)
    at sun.security.ssl.AbstractTrustManagerWrapper.check AdditionalTrust(SSLContextImpl.java:872)
    at sun.security.ssl.AbstractTrustManagerWrapper.check ServerTrusted(SSLContextImpl.java:814)
    at sun.security.ssl.ClientHandshaker.serverCertificat e(ClientHandshaker.java:1421)
    SR has been created.
    Any Tipps /Hints for me ?
    Thank You

    Originally Posted by robpet
    Should have said kind of the same problem...
    That was sort of my gut feelings so I checked our certificates beforehand and they are using certs with sha1 fingerprint. But we are not using SSL - our connections are made using port 389. And the communication status is green.
    But I cannot add SSL because it complains about "unable to obtain a valid certificate for SSL communication information. Please verify that the adress and port are correct and that the LDAP directory has been configured with a valid certificate.
    So I cannot understand why users cannot authenticate with zenagent.
    There's a TID about zcc login failures after 11.3 upgrade.
    https://www.novell.com/support/kb/doc.php?id=7014716
    We ran into the above.

  • Working of ComboBox in JSP

    I am new to jsp programming. I have no idea how to navigate if there is two dropdownlist. Here second one depends on the first one then should i have to design two pages with sam dessign?
    I have checked the url
    http://forum.java.sun.com/editwatches!default.jspa
    thsi page contains two comboboxes. I have selected java essentials from first combo. Then it got redirected to another page.
    with the url
    http://forum.java.sun.com/editwatches!default.jspa?filterCat=5
    When I checked the view source of http://forum.java.sun.com/editwatches!default.jspa
    I have seen something like this...
    <select name="filterForum"
    onchange="location.href='editwatches!default.jspa?filterForum='+this.options[this.selectedIndex].value+'&filterCat='+this.form.filterCat.options[this.form.filterCat.selectedIndex].value;">
    In the above code what do they mean by location?
    Please reply me
    Thanks in advance

    Hi,
    Well if you are looking for Dependent Dropdown problem...
    There are many solutions in order acheive this...
    checkout some of those...
    1).Save the present of the Form in a Bean with the scope of session and onChange of the first Combo box redirect it to a Controller(Servlet) Query the Database and save the results in the FormBean which we saved in the scope session and then redirect the formBean to the same JSP again...and now repopulate the second combo with new obtained results from the database and repopulate the rest of the form according to present FormBean state from the session.
    Here is a Typical example for you
    Assuming that a Servlet had already preloaded the first drop-down values from the database in a FormBean
    FormBean.java
    =============
    public class FormBean{
    private String firstDDValue = new String("");
    private ArrayList firstDDOptions = new ArrayList();
    private String secondDDValue = new String();
    private ArrayList secondDDOptions = new ArrayList();
    // Setters & getters for all the bean properties.
    }Form.jsp:
    =========
    <jsp:useBean id="formBean" class="com.formbeans.FormBean" scope="session"/>
    <%
      ArrayList fristDD = formBean.getFirstDDOptions();
      ArrayList secondDD = formBean.getSecondDDOptions();
      String firstDDValue = formBean.getFirstDDValue();
      String secondDDValue = formBean.getSecondDDValue();
      int FDSIZE = fristDD.size();
      int SDSIZE = secondDD.size();
    %>
    <form name="formBean">
    First DropDown:
    <select name="firstDropDown" onChange="if(this.value != '-1')window.location.href='ControlerServlet?firstDropDown='+escape(this.value);" >
    <option value="-1">Pick One</option>
    <%for(int i = 0;i < FDSIZE ; i++){
        String value = ((String[])firstDDOptions.get(i))[0];
        String text = ((String[])firstDDOptions.get(i))[1];
    %>
      <%if(value.equals(firstDDValue){)%>
       <option value="<%=value%>" selected="selected"><%=text%></option>
      <%}else{%>
       <option value="<%=value%>"><%=text%></option>
      <%}%>
    <%}%>
    </select>
    <BR/>
    <BR/>
    Second DropDown:
    <select name="secondDropDown">
    <option value="-1">Pick One</option>
    <%for(int i = 0;i < FDSIZE ; i++){
        String value = ((String[])secondDDOptions.get(i))[0];
        String text = ((String[])secondDDOptions.get(i))[1];
    %>
      <%if(value.equals(secondDDValue){)%>
       <option value="<%=value%>" selected="selected"><%=text%></option>
      <%}else{%>
       <option value="<%=value%>"><%=text%></option>
      <%}%>
    <%}%>
    </select>
    <BR/>
    <BR/>
    </form> NOTE: It would be a better practise if you can make use of JSTL tags to render the page in to make your View Page look more cleaner
    ControlerServlet.java
    =====================
    public doGet(request,response){
    String firstDropDown = request.getParameter("firstDropDown");
    HttpSession session = request.getSession();
    FormBean fb = (FormBean) session.getAttribute("formBean");
    fb.setFirstDDValue(firstDropDown); 
    fb.setSecondDDOptions(DAODelegate.getSecondDropDownData(firstDropDown));
    session.setAttribute(""formBean",fb);
    response.sendRedirect("/Form.jsp");
    }2).Make use of a Hidden IFrame by using which you reload the page and then Reload a Page after getting values from the database update the parent frame combo accordingly.
    3).Take help of AJAX call a Controller get the Response in XML/JSON and parse it and then update the second combo by the XML/JSON response.
    checkout an example by you can achieve this.
    index.jsp:
    =======
    <%@page language="java" %>
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>Automatic Dependent Drop-Down Updation</title>
         <script language="javascript">
          // Global Variable for XmlHttp Request Object  
          var xmlhttp
          // Timer Variables
          var c = 0
          var t
           /* A function which calls a servlet  named AjaxServlet to get XmlData using XmlHttpObject */    
            function refreshCombo(txt){
                xmlhttp = null
                // code for initializing XmlHttpRequest Object On Browsers like  Mozilla, etc.
                if (window.XMLHttpRequest){
                     xmlhttp = new XMLHttpRequest()
                // code for initializing XmlHttpRequest Object On Browsers like IE
               else if (window.ActiveXObject) {
                   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP")
               if (xmlhttp != null){
                  // Setting the Servlet url to get XmlData
                   url = "AjaxServlet?req="+txt;
                   // Course of Action That Should be Made if their is a change in XmlHttpRequest Object ReadyState NOTE : it is 4 when it has got request from CGI
                   xmlhttp.onreadystatechange = getResponseAction;
                   // Open the Request by passing Type of Request & CGI URL
                   xmlhttp.open("GET",url,true);
                   // Sending URL Encoded Data
                   xmlhttp.send(null);
               else{
                 // Only Broswers like IE 5.0,Mozilla & all other browser which support XML data Supports AJAX Technology
                 // In the Below case it looks as if the browser is not compatiable
                  alert("Your browser does not support XMLHTTP.")
          /* Used for verifing right ReadyState & Status of XmlHttpRequest Object returns true if it is verified */
          function verifyReadyState(obj){
             // As Said above if XmlHttp.ReadyState == 4 then the Page Has got Response from WebServer
              if(obj.readyState == 4){
               // Similarly if XmlHttp.status == 200 it means that we have got a Valid response from the WebServer
                if(obj.status == 200){               
                    return true
                 else{
                    alert("Problem retrieving XML data")
          /* Action that has to take place after getting reponse */
          function getResponseAction(){
              // Verifying State & Status
              if(verifyReadyState(xmlhttp) == true){
                  // Building a DOM parser from Response Object
                  var response = xmlhttp.responseXML.documentElement
                  // Deleting all the Present Elements in the Drop-Down Box
                  drRemove()      
                  // Checking for the Root Node Tag
                  var x = response.getElementsByTagName("option")
                  var val
                  var tex
                  var optn
                  for(var i = 0;i < x.length; i++){
                     optn = document.createElement("OPTION")
                     var er
                     // Checking for the tag which holds the value of the Drop-Down combo element
                     val = x.getElementsByTagName("val")
    try{
    // Assigning the value to a Drop-Down Set Element
    optn.value = val[0].firstChild.data
    } catch(er){
    // Checking for the tag which holds the Text of the Drop-Down combo element
    tex = x[i].getElementsByTagName("text")
    try{
    // Assigning the Text to a Drop-Down Set Element
    optn.text = tex[0].firstChild.data
    } catch(er){
    // Adding the Set Element to the Drop-Down
    document.SampleForm.state.options.add(optn)
    /* Function removes all the elements in the Drop-Down */
    function drRemove(){
    document.SampleForm.state.options.length = 0;
    </script>
    </head>
    <body>
    <pre> <h1>Refresh Drop-Down <div id='txt'> </div> </h1></pre>
    <form name="SampleForm">
    <table align="center">
    <tr>
    <td>Country:</td>
    <td>
    <select name="country" onchange="refreshCombo(this.value)">
    <option value="india">INDIA</option>
    <option value="US">United States</option>
    <option value="UK">United Kingdom</option>
    <option value="Saudi">Saudi</option>
    </select>
    </td>
    </tr>
    <tr>
    <td>State:</td>
    <td>
    <select name="state">
    <option value="-1">Pick One</option>
    </select>
    </td>
    </tr>
    </form>
    </body>
    </html>
    AjaxServlet.java:
    =============
    * AjaxServlet.java
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    * @author RaHuL
    * @version
    public class AjaxServlet extends HttpServlet {
        /** Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
         * @param request servlet request
         * @param response servlet response
        protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
            // Sets the content type made to xml specific
            response.setContentType("text/xml");
            response.setHeader("pragma","no-cache");
            response.setHeader("Cache-Control","no-cache");
            response.setHeader("Cache-Control","no-store");
           //Initializing PrintWriter
            PrintWriter out = response.getWriter();
            String req = request.getParameter("req");
            // Creating an instance of XmlBean Which generates XmlData From Business Logic specified
            XmlBean xml = new XmlBean(req);
            // Method to Generate XMLDATA
            String buffer = xml.getXmlData();
            // If Close of DB connections are succefull then write the content to the printstream
            if(xml.close() == true)
                out.write(buffer);   
            out.flush();                 
            out.close();
        protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
            // Calls a Method called processRequest Which Processes the request which was made by the Browser Page
            processRequest(request, response);
    }XmlBean.java:
    ===========
    * XmlBean.java
    import java.sql.*;
    import java.util.*;
    import java.io.*;
    * @author RaHuL
    public class XmlBean {
        private Connection con = null;
        private PreparedStatement pstmt = null;
        private ResultSet rs = null;
        private String req;
        // Setting CLASSURL path to TYPE I Driver
        private String CLASSURL = "sun.jdbc.odbc.JdbcOdbcDriver";
        /* Specifing CONNECTION PATH to a DSN named TestDsn
         * Please Make Sure you create a DSN Named TestDsn to your database which holds EMP table
        private String CONNECTIONURL = "jdbc:odbc:TestDsn";
        boolean IS_ESTABLISHED = false;
        /** Creates a new instance of XmlBean and also establishes DB Connections */
        public XmlBean(String req) {
            try{
                this.req = req;
                Class.forName(CLASSURL);
                con = DriverManager.getConnection(CONNECTIONURL,"admin","");
                IS_ESTABLISHED = true;
            } catch(SQLException sqe){
                sqe.printStackTrace();
            } catch(Exception exp){
                exp.printStackTrace();
        /* Generates XmlData For the Business Logic Specified */
        public String getXmlData(){
            String XmlBuffer = "";
            if(IS_ESTABLISHED == true){
                try{
                    pstmt = con.prepareStatement("SELECT stateid,statename FROM EMP where countryid=' "+req+" ' " );
                    rs = pstmt.executeQuery();
                    if(rs != null){
                        XmlBuffer = XmlBuffer + "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>";
                        XmlBuffer = XmlBuffer + "<!--  Edited by Rahul Sharma -->";
                        // Root Node
                        XmlBuffer = XmlBuffer + "<dropdown>";
                        while(rs.next()){
                            String value = rs.getString(1);
                            String text = rs.getString(2);
                            // Sub-root Node
                            XmlBuffer = XmlBuffer + "<option>";
                            // node which holds value of drop-down combo
                            XmlBuffer = XmlBuffer + "<val>"+value+"</val>";
                            // node which holds text for drop-down combo
                            XmlBuffer = XmlBuffer + "<text>"+text+"</text>";
                            XmlBuffer = XmlBuffer + "</option>";
                        XmlBuffer = XmlBuffer + "</dropdown>";
                }catch(SQLException sqe){
                    sqe.printStackTrace();
                } catch(Exception exp){
                    exp.printStackTrace();
            return(XmlBuffer);
        /* Closes the DB Connection Conmpletely */
        public  boolean close(){
            if(IS_ESTABLISHED == true){
                try{
                    pstmt.close();
                    con.close();
                    return(true);
                } catch(SQLException sqe){
                    sqe.printStackTrace();
                } catch(Exception exp){
                    exp.printStackTrace();
            return(false);
    }Sample XML Reponse generated:
    <?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>
    <!--  Edited by Rahul Sharma -->
    <dropdown>
    <option>
    <val>DEL</val>
    <val>New Delhi</val>
    </option>
    <option>
    <val>HAR</val>
    <val>HARYANA</val>
    </option>
    </dropdown>for further reference you may use the below articles
    http://www.it-eye.nl/weblog/2005/12/13/ajax-in-struts-implementing-dependend-select-boxes/
    http://www.it-eye.nl/weblog/2006/04/04/implementing-dependent-select-boxes-in-jsf/
    Hope this might help,if that does do not forget to assign/distribute Duke Stars which you have promised :)
    REGARDS,
    RaHuL

  • Can XMLHttpRequest post whole form ?

    Hi
    I use XMLHttpRequest to POST form data to a servlet. Is it really necessary
    to concatenate all input fields one by one like this ?
    httpRequest.send("vards="+document.forms[0].vards.value);From this doc it seems that it should be possible to send whole form at once
    http://www.xulplanet.com/references/objref/XMLHttpRequest.html
    I have tried things like httpRequest.send(document.forms[0]) and httpRequest.send(document), but it didn't work.
    my code:
            httpRequest.open("POST", "AjaxServlet", true);
            httpRequest.onreadystatechange= function () {processRequest(); } ;   
    httpRequest.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=ISO-8859-13');

    I realize that this thread is a little stale however it came up as the 2nd entry in my google search so I thought I'd post a workable solution, to what seems to be a common problem with little or no information available.
    function formData(formId) {
         formId=document.getElementById(formId)
         var postStr= '';
         for (i = 0; i < formId.elements.length; i++) {
              formElem = formId.elements;
              switch (formElem.type) {
                   case 'text':
                   case 'select-one':
                   case 'hidden':
                   case 'password':
                   case 'textarea':
                   postStr += formElem.name + '=' + escape(formElem.value) + '&'
              break;
    Just use the postStr variable in a valid XMLHttpRequest function set up to post data.
    ie.
         httpRequest.send(postStr);

Maybe you are looking for