<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Set attrubute to WebScriptRequest, or cast it to a class which allows setting attribute to it in Alfresco Forum</title>
    <link>https://connect.hyland.com/t5/alfresco-forum/set-attrubute-to-webscriptrequest-or-cast-it-to-a-class-which/m-p/53747#M19982</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG&gt;My question:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;How to set attributes in the&amp;nbsp;WebScriptRequest, or cast &lt;SPAN&gt;WebScriptRequest&amp;nbsp;&lt;/SPAN&gt;to another class which allows setting attributes to it?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My approach:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;The issue is, WebScriptRequest does not have set methods.&amp;nbsp;In order to overcome this, I attempted to cast WebScriptRequest to HttpServletRequest. Next in the&amp;nbsp;&lt;SPAN&gt;HttpServletRequest, I set my attribute.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am attempting code as the one below &lt;EM&gt;(which compiles, but throws the runtime error):&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;public class MyWebScript extends AAbstractWebScript{&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;public void execute(WebScriptRequest request, WebScriptResponse response) throws IOException {&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; HttpServletRequest httpReq = ((WebScriptServletRequest) request).getHttpServletRequest();&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; httpReq.setAttribute("name", "John");&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;The issue is:&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;With the approach above, the code compiles, but I get runtime error as below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;org.alfresco.repo.web.scripts.BufferedRequest cannot be cast to org.springframework.extensions.webscripts.servlet.WebScriptServletRequest&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 27 Feb 2018 16:10:36 GMT</pubDate>
    <dc:creator>raghav</dc:creator>
    <dc:date>2018-02-27T16:10:36Z</dc:date>
    <item>
      <title>Set attrubute to WebScriptRequest, or cast it to a class which allows setting attribute to it</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/set-attrubute-to-webscriptrequest-or-cast-it-to-a-class-which/m-p/53747#M19982</link>
      <description>My question:How to set attributes in the&amp;nbsp;WebScriptRequest, or cast WebScriptRequest&amp;nbsp;to another class which allows setting attributes to it?&amp;nbsp;My approach:The issue is, WebScriptRequest does not have set methods.&amp;nbsp;In order to overcome this, I attempted to cast WebScriptRequest to HttpServletRequest. Nex</description>
      <pubDate>Tue, 27 Feb 2018 16:10:36 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/set-attrubute-to-webscriptrequest-or-cast-it-to-a-class-which/m-p/53747#M19982</guid>
      <dc:creator>raghav</dc:creator>
      <dc:date>2018-02-27T16:10:36Z</dc:date>
    </item>
    <item>
      <title>Re: Set attrubute to WebScriptRequest, or cast it to a class which allows setting attribute to it</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/set-attrubute-to-webscriptrequest-or-cast-it-to-a-class-which/m-p/53748#M19983</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There are few basic rule/need when we do casting of an object in javaIn your case it does not satisfy those.For more details of it you can check below link.&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://stackoverflow.com/questions/5289393/casting-variables-in-java" title="https://stackoverflow.com/questions/5289393/casting-variables-in-java" rel="nofollow noopener noreferrer"&gt;Casting variables in Java - Stack Overflow&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You just mentioned that you would like to cast an&amp;nbsp;&lt;SPAN style="color: #727174; background-color: #ffffff;"&gt;WebScriptServletRequest in to&amp;nbsp;&lt;SPAN&gt;HttpServletRequest&amp;nbsp;, can you tell me the reason behind this.If not what is the exact requirement which you would like to achieve.If possible both.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #727174; background-color: #ffffff;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #727174; background-color: #ffffff;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Feb 2018 18:32:26 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/set-attrubute-to-webscriptrequest-or-cast-it-to-a-class-which/m-p/53748#M19983</guid>
      <dc:creator>krutik_jayswal</dc:creator>
      <dc:date>2018-02-27T18:32:26Z</dc:date>
    </item>
    <item>
      <title>Re: Set attrubute to WebScriptRequest, or cast it to a class which allows setting attribute to it</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/set-attrubute-to-webscriptrequest-or-cast-it-to-a-class-which/m-p/53749#M19984</link>
      <description>&lt;P&gt;You can get by the casting error like this:&lt;/P&gt;&lt;PRE&gt;WebScriptRequest webScriptRequest = ((WrappingWebScriptRequest) request).getNext();
WebScriptServletRequest webScriptServletRequest = (WebScriptServletRequest) webScriptRequest;&lt;/PRE&gt;</description>
      <pubDate>Fri, 25 Oct 2019 16:54:22 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/set-attrubute-to-webscriptrequest-or-cast-it-to-a-class-which/m-p/53749#M19984</guid>
      <dc:creator>lancestine</dc:creator>
      <dc:date>2019-10-25T16:54:22Z</dc:date>
    </item>
  </channel>
</rss>

