2 Replies Latest reply on Jan 14, 2009 9:22 AM by Wolfgang Knauf

    Problem with css files in login.jsp page

    Marcin Misiewicz Newbie


      In my webapp I have configured form-based authentication. Here is my the code snippet of my web.xml file :

       <web-resource-name>Protected resources</web-resource-name>
       <description>The role required to login to application</description>

      Authentication works ok.
      But when I wan't to customize look of the login.jsp page with css and use javascript, insted of css file or js file I get always login.jsp file. It looks like all the resources are protected event outside of the restricted area when I get redirected to the login.jsp.
      When I hit css or js file in the browser I get the correct value. Also when I hit login.jsp directly not through redirect.

      Here is the login.jsp :

      <%@ page language="java" contentType="text/html; charset=UTF-8"
      <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
      <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
      <title>Insert title here</title>
       <link rel="stylesheet" type="text/css" href="login.css" />
       <form method="POST" action="<%=request.getContextPath()%>/j_security_check">
       User: <input type="text" name="j_username" size="15"><br>
       Password: <input type="password" name="j_password" maxlength="20" size="15"><br>
       <INPUT TYPE="SUBMIT" VALUE="Send" >

      Does anybody had similar problem. What am I doing wrong ?


        • 1. Re: Problem with css files in login.jsp page
          Marcin Misiewicz Newbie

          When I turn on TCP/IP monitor I can see that the browser want to get /myapp/restricted/login.css not /myapp/login.css.

          And of course instead of content of css file I get login.jsp.

          Please help. I don't know what am I doing wrong.

          I guess there is something wrong with redirect to login.jsp. I think that after successful redirect the url in the browser should point to the login.jsp, but in my case it is still pointing to the restricted resource.

          I have tested this in FF, Chrome and IE and result is the same in every browser.
          I'm using jboss 5.0 GA.

          Thanks in advance

          • 2. Re: Problem with css files in login.jsp page
            Wolfgang Knauf Master

            Hi Martin,

            try this:

            <link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/login.css" />

            Explanation: you call a page like "/restricted/mypage.jsp", which redirects you to the login page. But your browser still sees "/restricted/mypage.jsp" (see address bar) and thinks that "login.css" is a relative URL in the "restricted" area.

            Hope this helps