Sun Java System Application Server Enterprise Edition 8.2 アップグレードと移行

フォームベース認証を使用するアプリケーション

Application Server 6.5 で開発され、フォームベース認証を使用するアプリケーションは、認証フォームまたはログインページに要求パラメータを渡すことができます。入力パラメータに基づいて認証パラメータを表示するようにログインページをカスタマイズすることもできます。

次に例を示します。

http://gatekeeper.uk.sun.com:8690/NASApp/test/secured/page.jsp?arg1=test&arg2=m

Application Server 8.2 は、ログインページ表示中の要求パラメータの引き渡しをサポートしません。フォームベース認証を使用し、要求パラメータを渡すアプリケーションは、Application Server8.2 に移行できません。このようなアプリケーションを Application Server8.2 に移植するには、コードの大幅な変更が必要です。代わりに、要求パラメータの情報をセッションに格納して、それをログインページの表示中に取得できます。

次に、この問題を解決するコード例を示します。

変更前の 6.5 のコードは次のとおりです。

---------index-65.jsp -----------
<%@page contentType="text/html"%>
<html>
<head><title>JSP Page</title></head>
<body>
go to the <a href="secured/page.htm">secured a rea</a>
</body>
</html>
----------login-65.jsp--------------
<%@page contentType="text/html"%>
<html>
<head> </head>
<body>
<!-- Print login form -->
<h3>Parameters</h3><br>
out.println("arg1 is " + request.getParameter("arg1"));
out.println("arg2 is " + request.getParameter("arg2"));
</body>
</html>

変更後の Application Server8.2 のコードは次のとおりです。

---------index-81.jsp -----------
<%@page contentType="text/html"%>
<html>
<head><title>JSP Page</title></head>
<body>
<%session.setAttribute("arg1","test"); %>
<%session.setAttribute("arg2","me"); %>
go to the <a href="secured/page.htm">secured area</a>
</body>
</html>

index-81.jsp は、セッションの要求パラメータの格納方法を示しています。

----------login-81.jsp--------------
<%@page contentType="text/html"%>
<html>
<head> </head>
<body>
<!-- Print login form -->
<h3>Parameters</h3><br>
<!--retrieving the parameters from the session -->
out.println("arg1 is"+(String)session.getAttribute("arg1"));
out.println("arg2 is” + (String)session.getAttribute("arg2"));
</body>
</html>