0

我有一个像这样编码的现有 JSP。

<% 
  if( (request.getParameter("userid")!=null) && (request.getParameter("token")!=null) ) {

     session.setParameter("USERID", request.getParameter(userid);
     session.setParameter("Token", request.getParameter(token);

     send.redirect(another.jsp);
  }
%>

< ----- here i have the normal HTML contents where i ask for userid from the user 
        and upon clicking submit, java script function openwindow() is called ----- >

function openwindow(){

   < -- here i open a modal window which calls a URL with userid (get method) 
        and as return value i get userid and token back. 
        Now i set this to document.Parent.userid and document.Parent.token --- >

    document.Parent.userid = retval.userid;
    document.Parent.token = retval.token;
    Parent.submit();
}

使用上面提到的JSP,我遇到了一个问题,当我使用 调用JSP时,由于设置了请求参数sample.jsp?userid=dhfgd&token=dhdhd,因此控件直接进入。another.jsp

为避免这种情况,请建议我一个可能的解决方案,而无需对代码进行太多更改。

4

1 回答 1

0

如果您想在实际页面的响应中包含由 as well生成的内容,请使用include而不是redirect to 。another.jspanother.jspsample.jsp

阅读更多关于jsp 转发和重定向之间的区别


您可以使用HttpServletRequest#getMethod()检索请求方法,然后如果 JSP 不支持 GET 请求,则只需发送一个错误页面。

于 2014-05-22T21:03:45.163 回答