• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Niko's Mock Exam - Servlets - Doubt

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello ranchers,

The following is question NO:41 from Niko's mock test for servlets.

Consider this code.
package library;
public class Book {
private String title;
public Book() {}
// get and set methods
}

<%-- input.jsp --%>
<html>
<body>
<form action="output.jsp">
<input type="text" name="title" value="Mathematics"/>
<input type="submit" value="OK" />
</form>
</body>
</html>

<%-- output.jsp --%>
<jsp:useBean id="book" class="library.Book" scope="request" >
<jsp:setProperty name="book" property="title" param="*" />
</jsp:useBean>
<html>
<body>
I like <jsp:getProperty name="book" property="title" />!
</body>
</html>

What is the output when the form is submitted? (1 correct answer)
a. I like null!
b. I like Mathematics!

The correct answer is a. I am unable to get why. Param=* synchronizes all request parameters with useBean right?
Can you help me with this? Thanks!!
 
B Muthusamy
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Got the answer! It is the syntax of jsp:setProperty standard action.

<jsp:setProperty name="book" property="title" param="*" /> - this is wrong

<jsp:setProperty name="book" property="*" /> - correct way..
 
Space pants. Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic