Page 1 of 1

No attributes passed from HttpServlet to JSP in custom administration extension

Posted: Fri Dec 29, 2017 3:47 pm
by Lucas Romier
To whom it may concern,

I am currently trying to write a custom extension, which should provide me an extended state of the administration page.
Therefore, I retraced the steps portrayed in the administration example and got a static webpage as my result.
Now, I would like to display some saved data on this webpage.
To achieve this, I tried to pass some attributes to the request in the HttpServlet

Code: Select all

doGet()
method, but the attribute list on the JSP side is always empty.

Does anyone know a working way of passing data between the Servlet and the JSP file?

Below is a listing of my source code:

Code: Select all

public class SettingsServlet extends HttpServlet{
   
   private static final long serialVersionUID = 1L;
   
   @Override
   protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException{
      request.setAttribute("foo", "data");
      
      getServletContext().getRequestDispatcher("/extended_settings.jsp").forward(request, response);
   }

   @Override
   protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
      doGet(request, response);
   }
   
}


Here is the JSP file's request code:

Code: Select all

<%="Request attributes" + Collections.list(request.getAttributeNames()).toString()%>

which returns an empty List

And my hivemodule.xml:

Code: Select all

   <contribution configuration-id="com.polarion.xray.webui.administrationPageExtenders">
      <extender
         name="Extended settings"
         parentNodeName="Notifications"
         parentNodeIconUrl="/polarion/icons/default/topicIcons/notification.png"
         iconUrl="/polarion/icons/default/topicIconsSmall/notification.png"
         pageUrl="/polarion/notificationSettings/extended_settings.jsp"
         projectScope="false"
         projectGroupScope="false"
         repositoryScope="true"/>
   </contribution>


Although the website shows up fine, no data is passed.
Any help is much appreciated!

Re: No attributes passed from HttpServlet to JSP in custom administration extension

Posted: Mon Jan 08, 2018 2:09 pm
by ALMighty
Hello! :D

As far as I see it, your question is more about the Java Server Pages technology than specifically about
the Polarion Application Lifecycle Management software. I do not wanna say your question is offtopic
but if your question is generally more about JSP and can be solved without knowing Polarion, than probably Stackoverflow can help you better than the Polarion Forum. :wink:

I just wanted to give you this advice because I do not want to have users waiting for their answer so long
and I think no one here on this board can deliver you the desired answer. :|

Re: No attributes passed from HttpServlet to JSP in custom administration extension

Posted: Tue Mar 27, 2018 3:44 pm
by jcordeiro
Im looking for the same answer.

But one thing i found out is that the class:

Code: Select all

public class SettingsServlet extends HttpServlet{

Is not doing a thing on that example. You can change it, delete it, do whatever you want with it and it will not have any effect on the example.
The jsp is being called directly with:

Code: Select all

pageUrl="/polarion/notificationSettings/extended_settings.jsp"


This very different from the com.polarion.example.servlet that actually uses classes to be implemented.

If any one knows how to send api objects (like ILogger service) to the jsp, please reply.