_________ is a security standard that prevents the browser from interpreting user input as script.
- CORS
- CSP
- CSRF
- HTTPS
Content Security Policy (CSP) is a security standard that prevents the browser from interpreting user input as a script. It helps mitigate the risk of XSS attacks by defining and enforcing a set of rules for how resources should be loaded on a web page.
When implementing CSP, the _________ directive is crucial in restricting resources the page can load.
- connect-src
- img-src
- script-src
- style-src
When implementing CSP, the connect-src directive is crucial in restricting resources the page can load. It controls which URLs the document is allowed to make requests to, helping prevent unwanted network requests that could pose security risks.
In an XSS attack, the _________ method of XSS involves the attacker injecting a script that is stored on the server.
- DOM-based
- Persistent
- Reflected
- Stored
In a stored XSS attack, the injected script is stored on the server and served to users, making it more dangerous.
_________ encoding is a common technique to prevent XSS by converting special characters into HTML entities.
- Base64
- HTML
- URL
- UTF-8
HTML encoding is a common technique to prevent XSS by converting special characters into HTML entities, making it difficult for attackers to inject malicious scripts.
To mitigate DOM-based XSS attacks, one should avoid using _________ directly with user input.
- document.write()
- getElementById()
- innerHTML
- setAttribute()
Mitigating DOM-based XSS involves avoiding direct use of the innerHTML property with user input, as it can be exploited to execute malicious scripts within the DOM.
A developer is implementing CSP for the first time. What common challenges might they face?
- Blocking Legitimate Scripts
- Compatibility Issues with Older Browsers
- Difficulty in Debugging
- Increased Load Times
Implementing Content Security Policy (CSP) for the first time may face compatibility issues with older browsers. These issues could arise due to the introduction of security restrictions that are not supported in older browser versions.
Initialization parameters for a servlet are configured in the _________ file.
- config.xml
- initparams.xml
- servlet.xml
- web.xml
Initialization parameters for a servlet are configured in the web.xml file.
What is the primary purpose of using WebSockets in web applications?
- Batch processing
- File storage
- Real-time communication
- Static content delivery
The primary purpose of WebSockets in web applications is to enable real-time communication between the client and server, allowing for interactive and dynamic updates without the need for constant polling.
Which Java API is used for creating WebSocket applications in Java EE?
- java.socket
- java.web
- javax.communication
- javax.websocket
The javax.websocket API is used for creating WebSocket applications in Java EE, providing classes and interfaces to work with the WebSocket protocol.
In the context of servlets, what is a key difference between HTTP and WebSocket protocols?
- Connectionless protocol
- Full-duplex communication
- Request-Response model
- Stateless communication
A key difference between HTTP and WebSocket protocols is that WebSocket enables full-duplex communication, allowing both the client and server to send messages independently in real-time.