Results 1 to 2 of 2
  1. #1
    jeremy.wilson is offline Member
    Join Date
    Jul 2009
    Location
    Seattle, WA
    Posts
    23
    Rep Power
    0

    Default Responding back to application's HTTP POST values with application/x-www-form-urlenc

    I am trying to communicate back to an executable (installer file) that is sending me values via HTTP POST but continue to run into problems with the HttpContentType being converted back to “text/html;charset=UTF-8” within OpenCMS 6.2.1.

    How do I set my pages’s response (HttpContentType) as “application/x-www-form-urlencoded” and keep it that way. I’ve tried a number of different methods directly within my blocks of JSTL EL logic but it seems as though OpenCMS is forcing the HttpContentType to revert back before I can communicate back to the application by way of out.print(“something”);

    Is this a known problem in OpenCMS 6.2.1? Is there something within the configuration files that I can do to prevent my attempts to responsd from being converted back to “text/html;charset=UTF-8”.

    Thanks in advance and I realized this is primarily a question about OpenCMS configuration but hopefully somebody here within the Java community has seen the problem and knows the solution.

    Here is the code (index.jsp) I’m trying to create the response back to the application with:

  2. #2
    jeremy.wilson is offline Member
    Join Date
    Jul 2009
    Location
    Seattle, WA
    Posts
    23
    Rep Power
    0

    Default

    Java Code:
    <%@ page session="false" %>
    <%@ taglib prefix="c" URI equal to "java_dot_sun_dot_com/jstl/core" %>
    
    <%@ taglib URI equal to "jakarta_dot_apache_dot_org/taglibs/regexp-1.0" prefix="rx" %>
    <%@ taglib URI equal to "jakarta_dot_apache_dot_org/taglibs/string-1.1" prefix="str" %>
    
    <%@ page import="java.io.*"%> 
    <%@ page import="java.util.*"%>
    <%@ page import="java.lang.*"%> 
    <%@ page import="java.net.*"%> 
    
    <%@ page import="javax.servlet.*"%> 
    <%@ page import="javax.servlet.http.*"%>
    <%@ page import="javax.servlet.http.HttpServletRequest"%> 
    <%@ page import="javax.servlet.http.HttpServletResponse"%>
    
    
    <jsp:useBean id="cms" class="org.opencms.jsp.CmsJspActionElement">
    <% cms.init(pageContext, request, response); %>        
    </jsp:useBean>          
    
    
    <%-- ******** set POST submission type, a) register, b) subscribe, or c) null which is the product update post  ***** --%>
    
    <c:set var="regcheck">register</c:set>
    <c:set var="regtype" value="${param.type}" />
    
    <c:choose>
    <c:when test="${regcheck == regtype}">
    
          <c:set var="email" value="${param.email}" />
          <c:set var="user" value="${param.user}" />
          <c:set var="company" value="${param.company}" />
          <c:out value="${company}"/>
          <c:set var="serial" value="${param.serial}" />
    
          <c:set var="currentProduct">Laplink Defrag Professional Edition</c:set>
          <c:set var="prod" value="${param.product}" />
    
          <c:set var="currentLanguage">EN</c:set>
          <c:set var="lang" value="${param.language}" />
    
    
          <c:set var="currentMajor">11</c:set>
          <c:set var="versionmaj" value="${param.versionmajor}" />
          <c:set var="currentMinor">0</c:set>
          <c:set var="versionmin" value="${param.versionminor}" />
          <c:set var="currentBuild">0000</c:set>
          <c:set var="versionbld" value="${param.versionbuild}" />
    
          <c:set var="serverresponse">OK</c:set>
    
    
          <%
          String strregtype = request.getParameter("type");
          String strregemail = request.getParameter("email");
          String strreguser = request.getParameter("user");
          String strregcompany = request.getParameter("company");
          String strregserial = request.getParameter("serial");
          String strregproduct = request.getParameter("product");
          String strreglanguage = request.getParameter("language");
          String strregversionmajor = request.getParameter("versionmajor");
          String strregversionminor = request.getParameter("versionminor");
          String strregversionbuild = request.getParameter("versionbuild");
    
          // TEST the HTTP POST values 
          String paramStringRegister = "type="+strregtype+"&email="+strregemail+"&user="+strreguser+"&company="+strregcompany+"&serial="+strregserial+"&product="+strregproduct+"&language="+strreglanguage+"&versionmajor="+strregversionmajor+"&versionminor="+strregversionminor+"&versionbuild="+strregversionbuild;
          %>
    
          <% 
             response.setStatus(response.SC_OK);
             response.setContentType("application/x-www-form-urlencoded");
             response.setHeader("Content-Type", "application/x-www-form-urlencoded");
             response.setHeader("Pragma", "No-cache");
             response.setHeader("Cache-Control", "no-cache");
          
             response.setHeader("result", "OK");
    
             // Respond to the application with OK result
             String result = "OK";
             out.print("result=" + result);
          %>
          <% response.setStatus(307); %>
          <% response.setHeader("Location", "/mysupport/register/ooreg.asp?"+paramStringRegister); %>
    
    </c:when>
    </c:choose>
    
    <c:set var="subcheck">subscribe</c:set>
    <c:set var="subtype" value="${param.type}" />
    
    <c:choose>
    <c:when test="${subcheck == subtype}">
    
          <%-- ****************************************
          //  get the HTTP POST values and set them as variables :
          //  1) type, 2) email and return OK | ERR
          //  for newsletter subscription HTTP POST submission  
          ****************************************--%>
    
          <%--  HTTP POST parameter type is equal to subscribe and email is equal to user email   ***** --%>
          <c:set var="email" value="${param.email}" />
          <c:out value="${email}"/>
          <c:out value="${subtype}"/>
    
          <% 
             response.setStatus(response.SC_OK);
             response.setContentType("application/x-www-form-urlencoded");
             response.setHeader("Content-Type", "application/x-www-form-urlencoded");
             response.setHeader("Pragma", "No-cache");
             response.setHeader("Cache-Control", "no-cache");
    
             response.setHeader("result", "OK");
    
             // Respond to the application with OK result
             String result = "OK";
             out.print("result=" + result);
    
          %>
          <% response.setStatus(307); %>
          <% response.setHeader("Location", "/mysupport/register/ooreg.asp"); %>
    
    </c:when>
    </c:choose>
    
    <c:set var="updatecheck"></c:set>
    <c:set var="updatetype" value="${param.type}" />
    
    <c:choose>
    <c:when test="${updatetype eq null}">
    
    
          <%-- set the current version number, product, and language values  ***** --%>
          <c:set var="currentProduct">Laplink Defrag Professional Edition</c:set>
          <c:set var="prod" value="${param.product}" />
    
          <c:set var="currentLanguage">EN</c:set>
          <c:set var="lang" value="${param.language}" />
    
          <c:set var="currentMajor">11</c:set>
          <c:set var="versionmaj" value="${param.versionmajor}" />
          <c:set var="currentMinor">0</c:set>
          <c:set var="versionmin" value="${param.versionminor}" />
          <c:set var="currentBuild">0000</c:set>
          <c:set var="versionbld" value="${param.versionbuild}" />
    
          <c:choose>
          <c:when test="${prod == currentProduct}">
                <c:choose>
                      <c:when test="${versionmaj == currentMajor}">
                            <c:choose>
                                  <c:when test="${versionmin == currentMinor}">
                                  <c:choose>
                                        <c:when test="${versionbld == currentBuild}">
    
                                              <c:set var="result">OK</c:set>
                                              <c:set var="update">0</c:set>
                                              <c:set var="updateid">NULL</c:set>
    
                                              <% 
                                                 response.setStatus(response.SC_OK);
                                                 response.setContentType("application/x-www-form-urlencoded");
                                                 response.setHeader("Content-Type", "application/x-www-form-urlencoded");
                                                 response.setHeader("Pragma", "No-cache");
                                                 response.setHeader("Cache-Control", "no-cache");
    
                                                 response.setHeader("result", "OK");
                                                 response.setIntHeader("update", 0);
                                                 response.setHeader("updateid", "NULL");
    
                                                 // Respond with 1) result, 2) update, and 3) updateid values
                                                 String result = "OK";
                                                 String update= "0";
                                                 String updateid= "NULL";
                                              
                                                 out.print("result=" + result + "&");
                                                 out.print("update=" + update + "&"); 
                                                 out.print("updateid=" + updateid); 
                                              %>          
                                        </c:when>
                                        <c:when test="${versionbld < currentBuild}">
                                        <%--  product and major version URL params match   ******** --%>
                                              <c:set var="result">OK</c:set>
                                              <c:set var="update">1</c:set>
                                              <c:set var="updateid">90017</c:set>
    
                                              <% 
                                                 response.setStatus(response.SC_OK);
                                                 response.setContentType("application/x-www-form-urlencoded");
                                                 response.setHeader("Content-Type", "application/x-www-form-urlencoded");
                                                 response.setHeader("Pragma", "No-cache");
                                                 response.setHeader("Cache-Control", "no-cache");
    
                                                 response.setHeader("result", "OK");
                                                 response.setIntHeader("update", 1);
                                                 response.setIntHeader("updateid", 90017);
    
                                                 // Respond with 1) result, 2) update, and 3) updateid values
                                                 String result = "OK";
                                                 String update= "1";
                                                 String updateid= "90017";
                                              
                                                 out.print("result=" + result + "&");
                                                 out.print("update=" + update + "&"); 
                                                 out.print("updateid=" + updateid); 
                                              %>
                                        </c:when>
                                  </c:choose>
                                  </c:when>
                            </c:choose>
                      </c:when>
                </c:choose>
          </c:when>
          </c:choose>
    
    </c:when>
    </c:choose>

Similar Threads

  1. Need help with HTTP POST communication to desktop application (installer)
    By jeremy.wilson in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 07-17-2009, 06:19 PM
  2. Communicating with desktop application via HTTP POST
    By jeremy.wilson in forum New To Java
    Replies: 2
    Last Post: 07-17-2009, 06:06 PM
  3. Replies: 0
    Last Post: 05-28-2009, 05:47 PM
  4. Storing Array from HTTP Post
    By kskinner in forum New To Java
    Replies: 1
    Last Post: 09-08-2008, 06:00 AM
  5. SOAP over HTTP/POST
    By sabatier in forum NetBeans
    Replies: 0
    Last Post: 07-10-2007, 08:04 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •