0

以下を追加して次のURLを入力しています

?UserID=XBBBB

index.jsp から proauth.xhtml まで、そして ProfileAuthorizationBean.java のバッキング Bean まで、XBBBB の UserID を取得しようとしています。

コードは最後まで進んでいますが、index.jsp の後で UserID=XBBBB パラメータが失われています。IOW、index.jsp の System.out は XBBBB をコンソールに出力しており、proauth.xhtml に転送されていると思います。ProfileutorizationBean で HttpServletRequest を取得すると、UserID のパラメーターがありません。

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="ISO-8859-1" %>
<html>
<head></head>
<body></body>
<%
request.setCharacterEncoding("UTF-8");
String UserID = request.getParameter("UserID");
if (UserID != null) {
   System.out.println(UserID);
   response.sendRedirect("proauth.xhtml?UserID=" + UserID);
}
%>
</html>


<!DOCTYPE html>
<html xmlns:h="http://java.sun.com/jsf/html"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:p="http://primefaces.org/ui"
  xmlns:c="http://java.sun.com/jsp/jstl/core">
 <h:head>
  <link rel="stylesheet" type="text/css" href="themes/local/tinstyle.css"/>
 </h:head>
 <script type="text/javascript">
 function doSubmit() {
  document.getElementById('proAuthForm:proAuthBtn').click();
 }
 </script>
 <h:body onload="doSubmit()">
 <h:form id="proAuthForm">
<p:commandButton id="proAuthBtn" value="" action="#{profileAuthorizationBean.doProfileAuth}" ajax="false" />  
 </h:form>
 </h:body>
</html>


public String doProfileAuth() {
 String retValue = "landingPage";
 try {

   HttpServletRequest request = (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();
   System.out.println(request.getParameter("UserID"));
.
.
.
} catch (Exception e) {
}
}
4

0 に答える 0