Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

MVC Architecture

 
Shaibaz Gadhwala
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone,
Can anyone tell me the answer for the following question
The designers of JSP put forward two recommendations of architecture, known as Model 1 and Model 2. In a Model 2 achitecture it is the job of a Servlet to recognize what data a JSP page requires, to retrieve it and pass it into the JSP page.
Given the above information, how can a Servlet dynamically register a Bean for use with a JSP page?
The options are
1> forward.registerBean(new Bean(), REQUEST_SCOPE);
2> pageContext.setAttribute(new Bean(), REQUEST_SCOPE);
3> <jsp:useBean id="id" scope="page" class = "<%=..%>"/>
4> servletContext.setAttribute(new Bean(), REQUEST_SCOPE);
5> jspEngine.registerBean(new Bean(), REQUEST_SCOPE);
Thanks in advance....
 
Shaibaz Gadhwala
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems no one is interested in replying to my questions of MVC Architecture....
A final call to all the sleeping nerds to help a desparate soul like me....
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this some sort of exam question, or have you a real need to do this? The simplest way to find out is to try each case and see what happens!
 
Kameswari Jyosyula
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi , I think the answer that this is an examination question ;-)and i think the answer is 3.
The web borwser sends a request to the sever through a JSP page which in turn calls bean and returns to the client the output.
Whenever the JSP page is called it automatically is transformed to a servlet.In the usebean tag you specify the class that is required.The scope has nothing to do with the way the bean is called from the servlet.
hth
Originally posted by Shaibaz Gadhwala:
Hello everyone,
Can anyone tell me the answer for the following question
The designers of JSP put forward two recommendations of architecture, known as Model 1 and Model 2. In a Model 2 achitecture it is the job of a Servlet to recognize what data a JSP page requires, to retrieve it and pass it into the JSP page.
Given the above information, how can a Servlet dynamically register a Bean for use with a JSP page?
The options are
1> forward.registerBean(new Bean(), REQUEST_SCOPE);
2> pageContext.setAttribute(new Bean(), REQUEST_SCOPE);
3> <jsp:useBean id="id" scope="page" class = "<%=..%>"/>
4> servletContext.setAttribute(new Bean(), REQUEST_SCOPE);
5> jspEngine.registerBean(new Bean(), REQUEST_SCOPE);
Thanks in advance....

 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
servletRequest.setAttribute(string,object);
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic