Newbie looking to create a new jsp page

This topic has 2 replies, 3 voices, and was last updated 7 years, 8 months ago by Peter Major.

  • Author
    Posts
  • #1819
     tjholmes66
    Participant

    I’m new to OpenAM, but not new to Java or Tomcat JSP pages, or servlets. We are using OpenAM ver. 10 I believe.

    We can login to our loadbalancer which takes us to the url:
    https://myapp.net:9443/sso/UI/Login?module=MyCustomAuth&goto=https://someotherurl
    I can see where this page is located in the tomcat/webapps/sso/config/auth/html/Login.jsp

    I just want to create a new jsp page in the same directory, but when try to go to the exact URL (https://myapp.net:9443/sso/config/auth/html/mytest.jsp), the JSP page just gives us all kinds of errors.
    When I try to run the page as: https://myapp.net:9443/sso/UI/mytest.jsp gives me a bunch of errors.
    I’d like to run the code this way? Do I have to create a servlet rather than create a jsp page.

    BTW, I notice I get the same errors form I try the other standard jsp pages like session_timeout.jsp.

    So, I am not sure if this is an OpenAM issue with configuration, or is this just a simple tomcat issue?

    Any help would be much appreciated. Thanks!

    #1866
     Nicolas Seigneur
    Participant

    For anything under /openam/UI/* this is indeed done through a servlet-mapping.

     /openam/WEB-INF/web.xml
    
      <servlet>
        <servlet-name>LoginServlet</servlet-name>
        <servlet-class>com.sun.identity.authentication.UI.LoginServlet</servlet-class>
      </servlet>
    
      <servlet-mapping>
        <servlet-name>LoginServlet</servlet-name>
        <url-pattern>/UI/*</url-pattern>
      </servlet-mapping>
    

    For pages like session_timeout.jsp they’re called through callbacks from the Login page.
    Do you really need to reside under /UI/*? I usually simply drop a JSP at the root of the WebApp and invoke it at /openam/test.jsp or in your case at /sso/test.jsp.

    #1877
     Peter Major
    Moderator

    One another important snippet from web.xml:

    <context-param>
        <param-name>jato:com.sun.identity.authentication.UI.*:moduleURL</param-name>
        <param-value>../UI</param-value>
    </context-param>

    Essentially endpoints matching the URL pattern of /UI/* will be captured by JATO’s LoginServlet, which will then do its own thing, and then forward the request to the corresponding ViewBean class (where the class name is determined by the path used, so /UI/Login will call LoginViewBean, and /UI/Logout will call LogoutViewBean).

    The ViewBean then does its own magic, and getDisplayURL will be invoked, which then will return the path to the JSP file (normally something like /config/auth/default/Login.jsp – depends on ResourceLookup class to determine which customized path fits the most), and then the returned JSP will be executed.

    Anyways, if you want to expose a custom JSP, the simplest thing would be to put it on the servlet context, and make sure its path doesn’t clash with a servlet-mapping in web.xml.

    • This reply was modified 7 years, 8 months ago by Peter Major.
Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

©2022 ForgeRock - we provide an identity and access platform to secure every online relationship for the enterprise market, educational sector and even entire countries. Click to view our privacy policy and terms of use.

Log in with your credentials

Forgot your details?