• Post Reply Bookmark Topic Watch Topic
  • New Topic

some questions on J2EE test  RSS feed

kathy Tsui
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There may be up to three correct answers to the following questions. I'm not sure aboout them and come here to get your help.

1. if the business logic of an existing application is implemented using a set of CGI programs, which of the following Java
technologies can be used to implement the CGI programs as a Java-based solution?
A. Servlets
B. Enterprise JavaBeans
C. Screen Scrapers

2. In the doPost() method of a servlet below, assuming that getNameFromDB() returns NULL. Which of the following
statements are correct?

public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter out=response.getWriter();
out.println("Hello, ");
String name = getNameFromDB();
if(name==null) {
response.sendError(HttpServletResponse.SC_NOT_FOUND, "Unable to get name");

A. It will throw an IllegalStateException
B. It will throw a NullPointerException while serving a request
C. It will throw an InvalidStateException while serving a request.
D. It will throw a ServletException while serving a request.
E. It will not throw any exception.

3. Assume that the subcontexts com and com/sams already exist in the JNDI directory. Upon excuting the "try"
blocks below, which of the following events will result?

Context ctx=new InitialContext();
catch(NamingException exe){
A. The context com/sams/book and the subcontext sams/book are automatically created.
B. The context com/sams/book is suscessfully created.
C. The contet com/sams/book is created and the subcontext sams/com/book are automatically created.
D. NameAlreadyBoundException is thrown.
E. No changes occur in the directory system.

For question 1, I think answer is A; question 2, I don't know how the servlet get commited. I checked its API. it is said that if the Servlet is already commited, sendError() would throw IllegalStateException. For question 3, my answer is B.

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!