No attributes passed from HttpServlet to JSP in custom administration extension

Description
Lucas Romier
Posts: 1
Joined: Fri Dec 29, 2017 3:34 pm

No attributes passed from HttpServlet to JSP in custom administration extension

Postby Lucas Romier » Fri Dec 29, 2017 3:47 pm

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!
Kind regards,
Lucas Romier

ALMighty
Posts: 75
Joined: Wed Apr 27, 2016 10:34 am
Location: Austria

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

Postby ALMighty » Mon Jan 08, 2018 2:09 pm

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. :|
---------------------------------------------------------------------------------------------------
Playing a good game is never lame. :D
Image

jcordeiro
Posts: 3
Joined: Tue Mar 27, 2018 3:34 pm

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

Postby jcordeiro » Tue Mar 27, 2018 3:44 pm

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.


Return to “Polarion Application Lifecycle Management (ALM)”

Who is online

Users browsing this forum: No registered users and 2 guests