Pregunta

Hi i trying to get a request Parameter that is a URL path to a file:

I'm using a template from a XSL file to "paste" a div with a onclick event:

<div onclick="openPDF(700,500,'getDoc?pathpdf={./.}&amp;type=pdf&amp;nocache='+Math.random(),'scrollbars=yes,toolbar=no,status=yes,resizable=yes,menubar=no,location=no');" align="center">
 <img src='Images/pdfIconsmall.png' width='12' style='height:12' />
</div>

THIS PART -> pathpdf={./.} will receive the url like so:

pathpdf=\\SERVER02\work\area51\docs\ws\00120130000261_101912.pdf

the parameter is sent has expected, but in server side when i try to do a System.out of that parameter i am presented with this value:

->->->Path: SERVER02workarea51docsws 00120130000261_101912.pdf

Is the escaping made by the servlet or is somwthing in my aplication doing that?

Thank you

EDIT

I made this in a different way from the answear below but similar:string-replace-all

  <xsl:when test="string-length(./.) &gt;0">
    <xsl:variable name="pathpdf">
      <xsl:call-template name="string-replace-all">
      <xsl:with-param name="text" select="./." />
      <xsl:with-param name="replace" select="'\'" />
      <xsl:with-param name="by" select="'\\'" />
          </xsl:call-template>
     </xsl:variable>
<div onclick="openPDF(700,500,'getDoc?pathpdf={$pathpdf}&amp;type=pdf&amp;nocache='+Math.random(),'scrollbars=yes,toolbar=no,status=yes,resizable=yes,menubar=no,location=no');" align="center">
 <img src='Images/pdfIconsmall.png' width='12' style='height:12' />
</div>
</xsl:when>
¿Fue útil?

Solución

You have to encode the URL parameter value before sending the request to the server.

This

pathpdf=\SERVER02\work\area51\docs\ws\00120130000261_101912.pdf

Needs to become this:

pathpdf=%5CSERVER02%5Cwork%5Carea51%5Cdocs%5Cws%5C00120130000261_101912.pdf

If you are submitting the request from a java application, encode all parameters with

URLEncoder.encode(parameterValue);


With XSLT, try:

url:encode('your_url_goes_here');
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top