title: How JSP page works with XSL
body: <p>I am struggling with JSP and XSL technologies. The following is the code that I saw in other person's project, which is quite confusing. For my understanding, this guy uses the xsl to render jsp like css to html. Is it necessary to write code like that? I thought that XSL is generated to transform XML, instead of doing what CSS does. I hope someone could explain it further to me, that would be a great help. Thanks in advance!</p>
  
  <p><strong><em>LoginAction.jsp</em></strong></p>
  
  <pre><code> &lt;%@page contentType="application/xml" import="uts.wsd.*" errorPage="error500.jsp"%&gt;&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;?xml-stylesheet type="text/xsl" href="loginAction.xsl"?&gt;
  
                              &lt;!-- Implement page styles + elements from .xsl --&gt;
  
  &lt;% 
  //get objects from .xml files
  String filePath = application.getRealPath("WEB-INF/users.xml"); %&gt;
  &lt;jsp:useBean id="usersApp" class="uts.wsd.UsersApplication" scope="application"&gt;
      &lt;jsp:setProperty name="usersApp" property="filePath" value="&lt;%=filePath%&gt;"/&gt;
  &lt;/jsp:useBean&gt;
  
  &lt;page&gt;
  
  &lt;%
  //get needed data
  
  String email = request.getParameter("email");
  String password = request.getParameter("password");
  //User user = null;
  %&gt;
  
  &lt;%
  //init login method from java class
  User user = usersApp.getUsers().login(email, password);
  
  if (user != null) { //login is successful
      session.setAttribute("user", user);
      response.sendRedirect("index.jsp");
       %&gt; 
  &lt;success /&gt;
  
  &lt;% 
  //if login is not successful
  } else { %&gt;
  &lt;fail /&gt;
  
  &lt;% } %&gt;
  
  &lt;/page&gt;
  </code></pre>
  
  <p>How the fail and success tags work in this page? Is it used to match the xsl?</p>
  
  <p><strong><em>loginAction.xsl</em></strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;xsl:stylesheet version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
  
      &lt;xsl:output method="html" indent="yes" /&gt;
  
      &lt;xsl:variable name="email" select="email" /&gt;
      &lt;xsl:variable name="password" select="email" /&gt;
  
      &lt;xsl:template match="page"&gt;
          &lt;html&gt;
              &lt;head&gt;
                  &lt;style&gt;
                        ......
                  &lt;/style&gt;
                  &lt;title&gt;Logging In...&lt;/title&gt;
              &lt;/head&gt;
              &lt;body&gt;
                  &lt;!-- Page layout --&gt;
  
                  &lt;div class="heading"&gt;
                      You are not logged in &lt;br /&gt;
                      &lt;a href="index.jsp"&gt;Index&lt;/a&gt; | &lt;a href="register.jsp"&gt;Register&lt;/a&gt;
                      &lt;br /&gt;
                  &lt;/div&gt;
              &lt;br /&gt;
              &lt;xsl:apply-templates /&gt;
              &lt;/body&gt;
          &lt;/html&gt;
      &lt;/xsl:template&gt;
  
      &lt;xsl:template match="success"&gt;
      &lt;br /&gt;
      &lt;hr /&gt;
          &lt;h1&gt;Login successful.&lt;/h1&gt;
          &lt;p&gt;Click &lt;a href="index.jsp"&gt;here&lt;/a&gt; to search through available articles.&lt;/p&gt;
      &lt;/xsl:template&gt;
  
      &lt;xsl:template match="fail"&gt;
          &lt;hr /&gt;
          &lt;h1 class="h1"&gt;Email and/or Password incorrect.&lt;/h1&gt;
          &lt;p&gt;Click &lt;a href="login.jsp"&gt;here&lt;/a&gt; to try again.&lt;/p&gt;
          &lt;br /&gt;
          &lt;p&gt;Click &lt;a href="register.jsp"&gt;here&lt;/a&gt; to create an account.
          &lt;/p&gt;
      &lt;/xsl:template&gt;
  
  
  &lt;/xsl:stylesheet&gt;
  </code></pre>