[opencms-dev] Responding back to application's HTTP POST valueswith HttpContentType=application/x-www-form-urlencoded
Ruben Malchow
ruben at disk0.de
Thu Aug 13 10:07:17 CEST 2009
hi,
first off, i would think that application/x-www-form-urlencoded is most
commonly used for requests, not for responses. second, i wonder what the
problem with this is ... i mean - what is the information contained in
the response that it cannot be sent in utf-8? if it was binary, i could
understand you don't want it to be sent as text/html ... but then you
probably wouldn't want urlencoding for binaries either.
so ... maybe you can provide some more information on the type of data
being sent/received?
Jeremy Wilson schrieb:
> Has anyone every experienced this problem or do you know of any
> possible solutions to it? Please let me know otherwise I'm completely
> stuck and will have to recode everything into PHP mostly from scratch.
>
>
>
>
>
>
>
> Jeremy Wilson | Web Developer | Laplink Software, Inc | 425.952.6029
> office | 425.952.6002 fax | mailto:jeremy.wilson at laplink.com |
> www.laplink.com
>
> From: opencms-dev-bounces at opencms.org
> [mailto:opencms-dev-bounces at opencms.org] On Behalf Of Jeremy Wilson
> Sent: Tuesday, August 04, 2009 10:43 AM
> To: opencms-dev at opencms.org
> Subject: [opencms-dev] Responding back to application's HTTP POST
> valueswith HttpContentType=application/x-www-form-urlencoded
>
>
>
> 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 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.
>
>
>
> Here is the code (index.jsp) I'm trying to create the response back to
> the application with:
>
>
>
> <%@ page session="false" %>
>
> <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
>
>
>
> <%@ taglib uri="http://jakarta.apache.org/taglibs/regexp-1.0"
> prefix="rx" %>
>
> <%@ taglib uri="http://jakarta.apache.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}">
>
>
>
> <%-- ****************************************
>
> // get the HTTP POST values and set them as variables :
>
> // 1) type, 2) product, 3) language, 4) versionmajor, 5)
> versionminor, 6) versionbuild,
>
> // 7) email, 8) user, 9) company and 10) serial values
>
> // for product registration HTTP POST submission
>
> ****************************************--%>
>
>
>
> <c:set var="email" value="${param.email}" />
>
> <c:out value="${email}"/>
>
> <c:set var="user" value="${param.user}" />
>
> <c:out value="${user}"/>
>
> <c:set var="company" value="${param.company}" />
>
> <c:out value="${company}"/>
>
> <c:set var="serial" value="${param.serial}" />
>
> <c:out value="${serial}"/>
>
>
>
> <c:set var="currentProduct">Laplink Defrag Professional
> Edition</c:set>
>
> <c:set var="prod" value="${param.product}" />
>
> <c:out value="${currentProduct}"/>
>
>
>
> <c:set var="currentLanguage">EN</c:set>
>
> <c:set var="lang" value="${param.language}" />
>
> <c:out value="${currentLanguage}"/>
>
>
>
> <%-- major, minor and version build values for Laplink Defrag
> 11.0.0000 ***** --%>
>
> <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>
>
> <c:out value="${serverresponse}"/>
>
>
>
> <%
>
> // Get the POST parameters from Laplink Defrag .EXE - should be
> passed in the HTTP request
>
> 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 from O&O Check for Updates to see
> what actual values are being passed.
>
> // String paramString =
> "&product="+product+"&language="+language+"&versionmajor="+versionmajor+
> "&versionminor="+versionminor+"&versionbuild="+versionbuild;
>
> // String paramStringSubscribe =
> "&type="+typeooreg+"&product="+product+"&language="+language+"&versionma
> jor="+versionmajor+"&versionminor="+versionminor+"&versionbuild="+versio
> nbuild;
>
> String paramStringRegister =
> "type="+strregtype+"&email="+strregemail+"&user="+strreguser+"&company="
> +strregcompany+"&serial="+strregserial+"&product="+strregproduct+"&langu
> age="+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);
>
>
>
> // <c:set var="serverresponse">OK</c:set>
>
> // <c:out value="${serverresponse}"/>
>
> %>
>
> <% response.setStatus(307); %>
>
> <% response.setHeader("Location",
> "http://www.laplink.com/mysupport/register/ooreg.asp?"+paramStringRegist
> er); %>
>
>
>
> <%--
> response.sendRedirect("http://www.laplink.com/mysupport/register/ooreg.a
> sp?"+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);
>
> // out.print("OK");
>
> %>
>
> <% response.setStatus(307); %>
>
> <% response.setHeader("Location",
> "http://www.laplink.com/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}">
>
>
>
> <%-- ****************************************
>
> // get the HTTP POST values and set them as variables :
>
> // 1) type, 2) product, 3) language, 4) versionmajor, 5)
> versionminor, 6) versionbuild,
>
> // for product registration HTTP POST submission
>
> **************************************** --%>
>
>
>
> <%-- set the current version number, product, and language values
> for Laplink Defrag 11.5.4165 ***** --%>
>
> <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}" />
>
>
>
> <%-- major, minor and version build values for Laplink Defrag
> 11.0.0000 ***** --%>
>
> <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}">
>
> <%-- product and major version URL
> parameters passed match ******** --%>
>
> <c:set var="result">OK</c:set>
>
> <c:set var="update">0</c:set>
>
> <c:set
> var="updateid">NULL</c:set>
>
>
>
> <%
>
> // <c:out
> value="${result}"/>
>
> // <c:out
> value="${update}"/>
>
> // <c:out
> value="${updateid}"/>
>
>
>
>
> 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 to the
> application 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
> parameters passed match ******** --%>
>
> <c:set var="result">OK</c:set>
>
> <c:set var="update">1</c:set>
>
> <c:set
> var="updateid">90017</c:set>
>
>
>
> <%
>
> // <c:out
> value="${result}"/>
>
> // <c:out
> value="${update}"/>
>
> // <c:out
> value="${updateid}"/>
>
>
>
>
> 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 to the
> application 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:when test="${prod != currentProduct}">
>
> <%-- do something in the event that none of the above
> parameters sent from O&O are matched --%>
>
>
>
> <%-- user URL parameters are less than major and minor
> versions specified above ******** --%>
>
> <c:set var="result">OK</c:set>
>
> <c:out value="${result}"/>
>
>
>
> <% response.setStatus(response.SC_OK); %>
>
> <%--
> response.setContentType("application/x-www-form-urlencoded"); --%>
>
> <% response.setHeader("ContentType",
> "application/x-www-form-urlencoded"); %>
>
>
>
> <% response.setHeader("result", "ERR"); %>
>
>
>
> <%
>
> // Respond to the application with OK result
>
> String result = "OK";
>
> out.print("result=" + result);
>
> %>
>
> <p>Your product does not match our list of available
> products. There is no update for <c:out value="${prod}"/> <c:out
> value="${versionmaj}"/>.<c:out value="${versionmin}"/>.<c:out
> value="${versionbld}"/> available here.</p>
>
>
>
> </c:when>
>
>
>
> <c:otherwise>
>
> <%-- user come to the page with no URL parameters
> ****************** --%>
>
> <c:set var="result">OK</c:set>
>
> <c:out value="${result}"/>
>
>
>
> <% response.setStatus(response.SC_OK); %>
>
> <%--
> response.setContentType("application/x-www-form-urlencoded"); --%>
>
> <% response.setHeader("ContentType",
> "application/x-www-form-urlencoded"); %>
>
>
>
> <% response.setHeader("result", "OK"); %>
>
> <% response.setIntHeader("update", 0); %>
>
> <% response.setHeader("updateid", "NULL"); %>
>
>
>
> <%
>
> // Respond to the application with OK result
>
> String result = "OK";
>
> out.print("result=" + result);
>
> %>
>
>
>
> <p>No URL parameters branch</p>
>
>
>
> </c:otherwise>
>
> </c:choose>
>
>
>
> </c:when>
>
> </c:choose>
>
>
>
> Jeremy Wilson | Web Developer | Laplink Software, Inc | 425.952.6029
> office | 425.952.6002 fax | mailto:jeremy.wilson at laplink.com |
> www.laplink.com
>
> No virus found in this incoming message.
> Checked by AVG - www.avg.com
> Version: 8.5.392 / Virus Database: 270.13.43/2280 - Release Date:
> 08/04/09 05:57:00
>
>
>
>
> ------------------------------------------------------------------------
>
>
> _______________________________________________
> This mail is sent to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://lists.opencms.org/mailman/listinfo/opencms-dev
More information about the opencms-dev
mailing list