如果用户登录无效,我正在尝试在index.jsp页面中显示错误消息。
这是我的servlet代码:
if( passwordService.authenticate(password, attemptedPassword, salt)){
User user = LogicFacade.login(email, password);
HttpSession session = request.getSession();
session.setAttribute("user", user);
session.setAttribute("role", user.getRole());
return user.getRole() + "page"; // i return the name of the jsp page, to get to the next jsp page
}else{
//here I make the error message I want to show
String errorMessage ="The retrived password or username did not match";
request.setAttribute("errorMessage", errorMessage );
RequestDispatcher rd = request.getRequestDispatcher("/index.jsp");
rd.forward(request, response);
}
} catch (SQLException | NoSuchAlgorithmException | InvalidKeySpecException | ServletException | IOException ex) {
Logger.getLogger(Login.class.getName()).log(Level.SEVERE, null, ex);
}
return null;
}
}
这里我在jsp中显示它:
<%
if(null!=request.getAttribute("errorMessage"))
{
out.println(request.getAttribute("errorMessage"));
out.println("<p> Error!! </p>");
//ved godt det ikke er super smart at printe paragraph tags med ud
}
%>
为什么信息没有显示?
答案 0 :(得分:0)
尝试这可以解决您的问题
#include <bits/stdc++.h>
using namespace std;
std::map<unsigned long long,unsigned long long> F;
unsigned long long fib(unsigned long long n)
{
if(n==-1) return 0; // Shifting index by 1
if(n==0) return 1;
if(n==1) return 1;
if(F.find(n) != F.end()) return F[n]; // This seems to be the problem,
else
{
if(n%2==0) //
{
F[n/2-1] = fib(n/2-1)%1000000007;
F[n/2] = fib(n/2)%1000000007;
return F[n] = (F[n/2-1]*F[n/2-1]+F[n/2]*F[n/2])%1000000007;
}
else
{
F[n/2] = fib(n/2)%1000000007;
F[n/2+1] = fib(n/2+1)%1000000007;
return F[n] = (F[n/2]*(2*F[n/2+1]-F[n/2]))%1000000007;
}
}
}
int main() {
unsigned long long int broj;
cin >> broj; // input the number
cout << fib(broj-1) << endl;
return 0;
}