• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Some Brainbench JSP Q's.....Opinions required

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are writing a JSP/Servlet Web application that will execute in a Web container located on a Linux server. Your Web application is required to access an Oracle customer database on a Solaris server and an MS SQL inventory database running on Windows 2000. All systems are running on a local intranet. Referring to the application description above, what JDBC driver is appropriate?
Type 1
Type 2
Type 3
Type 4
Type 2 or 4 (depending on vendor)

Which JSP tag transfers the processing completely to another resource such that the output does NOT include any output specified in the original JSP?
<jsp aram>
<jsp:include>
<jsp:forward>
<jsp:setProperty>
<%@ response redirect %>
Which statement is true for a Web application that is distributed across multiple servers?
You cannot use sendRedirect().
You cannot depend on events generated when a session is activated or passivated.
You cannot use HttpSession.
You cannot use RequestDispatcher.include() or RequestDispatcher.forward().
You cannot share application information with ServletContext.


Which one of the following URLs can be used inside a <jsp:include /> statement?
https://www.xyz.com
/f1/temp1.jsp
ftp://ftp.xyz.com/dir1/temp1.jsp
http://www.xyz.com/jsp
http://www.xyz.com/code/tt.jsp

<jsp:forward page="eBusiness.jsp" />
Within a JSP document, where can the above code appear, given that the JspWriter's buffer will NOT be flushed until the end of the JSP page has been reached?
Only on the very first line of the document
Only before any directives
Anywhere within the document
Only before any declarations
Only before any scriptlets that write output to the Response object

By default, a client has access to all of a Bean's properties.
Given the above context, how can you prevent a client from accessing sensitive Bean properties?
Do not place the Bean in the root or virtual root directory.
Mark sensitive Bean attributes as "Read-Only" in BeanInfo PropertyDescriptors.
Use a shadow Bean, also known as a proxy Bean, to set non-sensitive Bean properties.
Use a firewall or a proxy to discourage data from being sent back to the client browser.
Avoid revealing the name of sensitive properties by not using Bean aliases

The majority of the integration of JSP pages within the J2EE platform is inherited from the reliance on what specification?
EJB 1.1
JSP 1.1
HTTP 4.0
JNDI
Servlet 2.2

Which one of the following is a Java keyword used in a class definition to specify that a class is NOT to be instantiated but inherited by other classes?
ownership
throws
abstract
exception
interface
Which one of the following is NOT a requirement for having the JSP-generated servlet extend "my own custom servlet class," instead of the default?
The init() method has to invoke the jspInit() method.
All methods in the Servlet interface must be declared final.
Each .class file must be signed by a Certificate Authority (CA).
The destroy() method has to invoke the jspDestroy() method.
The service() method has to invoke the _jspService() method.

The memory footprint of a JSP page can be measured by serializing the generated JSP Servlet to disk and seeing how large that file is. Which one of the following statements about the above approach is TRUE?
This approach is too slow to perform on a live system.
The measurement is not accurate.
JSP pages do not have access to the Server's hard drive.
Serialization will not take into account objects referenced by the JSP page in all cases.
JSP pages cannot serialize JSP Servlets.

What effect on variables does the keyword "static" have when used in the declaration section of a JSP page?
Static cannot be used because it is a server-assigned keyword and will throw an exception error.
Its value is shared by all instances of the class.
Static must be assigned as a variable within an array before use.
Static is similar to declaring an include variable in the declaration section.
The static keyword is ignored when used within the declaration section.

50. A security policy domain is a scope over which security policies are defined and enforced by a security administrator.
Based on the information above, which one of the following is NOT a characteristic of a security policy domain upon which a JSP can run?

The security policy ensures that multiple security policy domains can exist within a single technology domain.
The security policy may have groups to simplify setting of security policies.
The security policy uses a well-defined authentication protocol(s) for authenticating users.
The security policy has a collection of users or principals.
The security policy contains an object that encapsulates single state information between two entities.


51. <html>
<body>
<jsp:include file="sidemenu.html"/>

<jsp:useBean id="checkout" scope="page" class="com.shop.CheckOut" />
<% if (checkout.ifTransactionComplete()) { %>
<jsp:forward page="confirmpurchase.jsp" />
<% } %>

<jsp:include file="checkout.html"/>
</body>
</html>
Assume that the sample sales JSP page above for an e-commerce store is syntactically correct. Why does the page sometimes result in an IllegalStateException being thrown?



The jsp:useBean tag must be declared at the top of the file.
One of the relative URLs does not exist.
The sample JSP page is not thread safe.
The jsp:forward cannot be called after jsp:include.
The jsp:forward only works if the JSP buffer has been flushed prior to the jsp:forward call.

52. Your Java applet, which needs to be sent to a browser by means of a JSP page, is contained within a JAR file called foo.jar.
Based on the scenario above, how can the browser download this JAR file?

Recompile the .JAR file to a .class file
Rename the foo.jar file to .js
Add an archive="foo.jar" line to the plugin statement
Embed the applet within the JSP page itself
Add the .JAR file to a .ZIP file for the client browser to download

53. <%!
HashMap users2resource = new HashMap();
%>
<% HashMap people = new HashMap() %>
<% users2resource.put(..) %>
<% int j;
j = j+1; %>
.
.
.
<%= users2resource.get(..) %>
What potential problem, if any, exists for the sample JSP page above?

j = j+1 is not atomic.
The users2resource is not thread safe.
The resources put into people will never be garbage collected.
The people is not thread safe.
There is no problem.

54. Which one of the following is NOT a valid reason to use the <jsp:useBean> tag instead of instantiating beans directly inside scriptlets?

Instantiating beans directly inside a scriptlet can allow malicious code to access the client browser.
If the variable is persistent (session or application), useBean initializes it if necessary but fetches the variable if it already exists.
The useBean has a "scope" parameter that automatically determines whether the bean should be stored as a local variable, within the request object, within the session object, or within the ServletContext object.
The tag syntax is arguably less intimidating to HTML designers.
The tags are potentially more portable to future versions of the JSP spec, or alternate implementations.

55. <%
Cookie mycookie = new Cookie("aName","aValue");
response.addCookie(mycookie);
%>
Where is the above code fragment located to set this cookie at the client?

Before <language> is set
At the beginning of a JSP page
Anywhere before the output stream to the client is emptied
After the headers and before the first script tag
Within the first <script> tag

56. try{
String s="X";
int i=Integer.parseInt(s);
}
catch(NumberFormatException ex){
System.out.println(s + " can't be converted to an int");
return;
}
finally{
System.out.println("The sky is blue.");
}
In the above code fragment, when does the "finally" exception handler execute?

Always
When int=I is equal to a number above zero
When String=S is equal to X
When int=I is a string
After NumberFormatException has been thrown

57. Which one of the following results in an error stating that a Java Bean was NOT found?

You have not compiled your applet using the latest API.
The JSP0.9 Engine does not support Java Beans.
You are trying to write a second response to the client browser.
You have attempted to use the getProperty action before the useBean tag.
You have set "lang=" incorrectly.
 
I AM MIGHTY! Especially when I hold this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic