Web Technologies: JavaScript, JSP, and Servlets
Test your knowledge of web development technologies including JavaScript fundamentals and Java server-side programming with JSP and Servlets.
Questions
What is used as a separator in a domain name ?
- colon(:)
- slash(/)
- dot(.)
- All the above
What is happening behind the scenes is that your JSP is being turned into a Java file, compiled and loaded. This compilation only happens once, so after the first load, the file doesn't take long to load anymore.
- True
- False
JSP simply puts Java inside HTML pages. You can take any existing HTML page and change its extension to ".jsp" instead of ".html".
- True
- False
Jsp Page can be excuted from the below, (choose multiple)
- Tomcat
- Weblogic
- Websphere
- None of the above
What tools can be used to generate the multiple views in jsp?
- xalan-J
- Saxon
- Jdk1.5
- None of the above
What line of code below might be combined in the same JSP page with a validation guard (for example, <% bean.validationGuard(); %> ), in order to create an alternate flow of control for scenarios in which exceptions arise. The validationGaurd method might throw an exception, which should cause the flow of control to continue in another user-defined page (assume JSP 1.0).
- <jsp:error page="errorPage.jsp" guard="true" />
- <%@ page language="java" buffer="8k" %>
- <jsp:useBean id="bean" class="examples.Bean" scope="request" />
- <%@ page language="java" errorPage="errorPage.jsp" buffer="8k" %>
What is the difference between doing an include or a forward with a RequestDispatcher?
- The forward method transfers control to the designated resource, while the include method invokes the designated resource, substitutes its output dynamically in the display, and returns control to the calling page.
- The two methods provide the same functionality, but with different levels of persistence.
- The forward method is deprecated as of JSP 1.1 and the include method should be used in order to substitute portions of a dynamic display at runtime.
- The include method transfers control to a dynamic resource, while the forward method allows for dynamic substitution of another JPS pages output, returning control to the calling resource.
What is the initial contact point for handling a web request in a Page-Centric architecture?
- A JSP page
- A JavaBean
- A servlet
- A session manager
Are custom tags available in JSP 1.0? If not, how else might you implement iteration from within a JSP?
- Yes, but the only tags available relate to database access.
- No. To iterate over a collection of values, one must use scriptlet code.
- No, but there is a standard <iterate> tag that may be used.
- Yes, but custom tags will not help developers create tags for use in iterating over a collection.
Choose the statement that best describes how to connect JSP pages and Enterprise JavaBeans (EJBs):
- Lookup the EJBs from within a JSP, but use the EJBs from within a basic JavaBean.
- Lookup and use the EJBs from a separate business delegate. The JavaBeans that work with JSP pages are clients to these business delegates and know nothing about EJB specifics.
- Lookup and use the EJBs from within a JSP page, but only as remote references.
- Lookup the EJBs from within a servlet, delegating usage to specific JSP pages.
What type of scriptlet code is better-suited to being factored forward into a servlet?
- Code that deals with logic that is common across requests.
- Code that deals with logic that is vendor specific.
- Code that deals with logic that relates to database access.
- Code that deals with logic that relates to client scope.
What alternatives exist to embedding Java code directly within the HTML markup of your JSP page?
- Moving the code into your session manager.
- Moving the code into scriptlets.
- Moving the code into JavaBeans and servlets.
- Moving the code into a transaction manager.
Why use RequestDispatcher to forward a request to another resource, instead of using a sendRedirect?
- Redirects are no longer supported in the current servlet API.
- Redirects are not a cross-platform portable mechanism.
- The RequestDispatcher does not use the reflection API.
- The RequestDispatcher does not require a round trip to the client, and thus is more efficient and allows the server to maintain request state.
What is a benefit of using JavaBeans to separate business logic from presentation markup within the JSP environment?
- It allows the JSP to access middleware.
- It creates a cleaner role separation between the web-production team and the software development team, so that the web-production team can focus on presentation markup, while the software team can focus on building reusable software components for helpin
- It provides a dynamic markup environment, such that JavaBeans are integrated seamlessly with the template presentation content, in order to create the dynamic display for the client.
- It provides the developer with full access to the Java 2 Platform Enterprise Edition (J2EE), which is unavailable from outside the JavaBean environment.
Choose the statement that best describes the relationship between JSP and servlets:
- Servlets are built on JSP semantics and all servlets are compiled to JSP pages for runtime usage.
- JSP and servlets are unrelated technologies.
- Servlets and JSP are competing technologies for handling web requests. Servlets are being superseded by JSP, which is preferred. The two technologies are not useful in combination.
- JSPs are built on servlet semantics and all JSPs are compiled to servlets for runtime usage.
A tag library is a collection of custom tags.
- True
- False
Inside which HTML element do we put the JavaScript?
- <script>
- <scripting>
- <js>
- <javascript>
What is the correct JavaScript syntax to write "Hello World"?
- response.write("Hello World")
- "Hello World"
- document.write("Hello World")
- ("Hello World")
Where is the correct place to insert a JavaScript?
- The <body> section
- Both the <head> section and the <body> section are correct
- The <head> section
- None of the above