Search code examples
javaauthenticationweblogicweb.xml

can i put the form-login-page html in a library for a webapp?


I was trying to create an app with login page authentication. And for the same i added <form-login-page> into the web.xml (as shown below).

I jar'ed the logon.html and logonerror.html , and added them as a library along with the .war webapp file. (under WEB-INF/lib/logon.jar) .

But when I am deploying the app , am getting ERROR 404 , logon.html not found error. Any pointers to why ? Cant i keep the logon files (htmls,js,css files) in a library ?

<?xml version="1.0" encoding="UTF-8" standalone="no"?>

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
         version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee">
<filter>
    <filter-name>MyFilter</filter-name>
    <filter-class>MyFilter</filter-class> 
     <init-param>
        <param-name>Domainname</param-name>
        <param-value></param-value>
    </init-param>
</filter>
<filter-mapping>
    <filter-name>MyFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping> 

<security-constraint>
    <web-resource-collection>
        <web-resource-name>SecuredResources</web-resource-name>
        <url-pattern>/*</url-pattern>       
    </web-resource-collection>
    <auth-constraint>
        <role-name>Default_Role</role-name>
    </auth-constraint>
        <user-data-constraint>             
         <transport-guarantee>CONF</transport-guarantee>
    </user-data-constraint>
</security-constraint>

<login-config>
    <auth-method>FORM</auth-method>
    <form-login-config>
      <form-login-page>/logon.html</form-login-page>
      <form-error-page>/logonerror.html</form-error-page>
    </form-login-config>
  </login-config>  

   <security-role>
    <role-name>Default_Role</role-name>
  </security-role>

</web-app>

Solution

  • My understanding is that a WAR will only expose the resources contained within its own root file structure. Hence the work-arounds (weblets, Maven config) mentioned in the answers to this question. You could make a custom build script that unpacked the content of logon.jar into your WAR, but I definitely wouldn't recommend that sort of hack. With a little more information concerning why you want to do this someone may be able to provide a better approach.