如何在JSP/Servlet Web应用程序中防止XSS攻击?
我正在创建我的第一个项目Java EE 7,但我遇到了麻烦.感谢任何帮助.
应用程序启动时,Tomcat日志显示以下消息:
"validateJarFile (C:\...\build\web\WEB-INF\lib\javaee-api-7.0.jar)-jar not loaded. See Servlet 2.3 Spec, section 9.7.2. Offending class: javax/servlet/Servlet .class"
Run Code Online (Sandbox Code Playgroud)
当我点击调用托管bean的按钮时,我收到错误:
Advertência: /index.xhtml @18,66 value="#{indexMB.user}": Target Unreachable, identifier 'indexMB' resolved to null
javax.el.PropertyNotFoundException: /index.xhtml @18,66 value="#{indexMB.user}": Target Unreachable, identifier 'indexMB' resolved to null
Run Code Online (Sandbox Code Playgroud)
IndexMB
@Named("indexMB")
@RequestScoped
public class IndexMB {
private String password;
private String user;
public String loginTest(){
return (this.user.equals("admin") ? "adminPage" : "inOutPage");
}
// getters and setters
}
Run Code Online (Sandbox Code Playgroud)
的index.xhtml
<html ...>
<f:loadBundle …Run Code Online (Sandbox Code Playgroud) 如果我有
ArrayList<Person> persons
Run Code Online (Sandbox Code Playgroud)
我如何在EL中访问它?
<c:foreach items="${what goes here??}" var="person">${person.title}</c:foreach>
Run Code Online (Sandbox Code Playgroud) JSP代码是:
<jsp:useBean id="person" class="org.example.model.PersonModel" scope="session">
</jsp:useBean>
<br> Name : <jsp:getProperty property="name" name="person"/>
<br> Surname : <jsp:getProperty property="surname" name="person"/>
Run Code Online (Sandbox Code Playgroud)
虽然我在request范围内设置了java对象,而不是在sessionController Servlet 中的范围内,我将请求转发给此Servlet.<jsp:useBean>虽然标记中提到的范围是会话,但如何获取请求属性?如果它用于pageContext.findAttribute()获取属性,那么在该<jsp:useBean>标记中使用scope属性有什么用?