Which allows embedding Java code directly into the HTML code?
- Applet
- JSP
- JavaBean
- Servlet
JavaServer Pages (JSP) allows the embedding of Java code directly into HTML code, facilitating the creation of dynamic web pages with server-side logic.
In the lifecycle of JSP, after the translation phase, it undergoes the ______ process.
- compilation
- destruction
- execution
- initialization
After the translation phase, JSP undergoes the execution process, where the generated servlet is executed to produce dynamic content.
JSP is a technology on the server side to make ______ easier.
- Client-side scripting
- Java programming
- Server-side scripting
- Web development
JSP (JavaServer Pages) is a technology on the server side to make server-side scripting easier. It allows the embedding of Java code in HTML pages for dynamic content generation.
Which method of the HttpServlet class is used to handle HTTP GET requests?
- doGet()
- doPost()
- init()
- service()
The doGet() method of the HttpServlet class is specifically designed to handle HTTP GET requests.
How should a servlet handle session tracking when a user's privacy settings restrict cookie usage?
- Database Session
- HTTP Session
- Hidden Form Fields
- URL Rewriting
When a user's privacy settings restrict cookie usage, session tracking can be handled using Hidden Form Fields. This involves including session information in HTML forms.
The servlet is removed from service by the servlet container via the __________ method.
- destroy()
- doDelete()
- init()
- service()
The destroy() method is called when the servlet is being removed from service by the servlet container. It allows the servlet to release resources before it's taken out of operation.
What differentiates ServletContext and ServletConfig in terms of initialization parameters?
- ServletConfig can be used for application-wide parameters, while ServletContext is specific to a servlet.
- ServletConfig is used for application-wide parameters.
- ServletContext can be used for application-wide parameters, while ServletConfig is specific to a servlet.
- ServletContext is used for servlet-specific parameters.
The ServletContext is intended for parameters that are shared across the entire application, whereas ServletConfig is specific to a particular servlet.
Can a servlet access the ServletConfig of another servlet?
- It depends on the web container being used.
- No
- Only if both servlets belong to the same package.
- Yes
No, a servlet cannot directly access the ServletConfig of another servlet. Each servlet has its own ServletConfig associated with it.
The deployment descriptor file used to configure a servlet in a web application is named __________.
- servlet-config.xml
- web-app.xml
- web-config.xml
- web.xml
The deployment descriptor file used to configure a servlet in a web application is named web.xml.
What is the significance of the path attribute in a cookie?
- It defines the cookie's value
- It indicates the cookie's path
- It sets the cookie's domain
- It specifies the cookie's name
The path attribute in a cookie is significant as it indicates the URL path for which the cookie is valid. The client sends the cookie only if the path matches the requested URL.