Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java bean

 
mayank jamindar
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Plz help me answer the following query:
Consider the code for a java bean
(public class TicketBean
{
int price;
String name;
// assume usual getters and setters.
}

):
Also consider the following code for ticketview.jsp:

<html>
<head></head>
<body>
<jsp:useBean id="ticket" class="TicketBean"/>
<jsp:setProperty name="ticket" property="*"/>
Name : <%=ticket.getName()%>
Price : <%=ticket.getPrice()%>
</body>
<html>
Which of the following lines will be in the output of the jsp page, if it is accessed through URL:
http://servername/ticketview.jsp?name=AAA


Do you think Since Price is not set It will give Error? If now what will happen when value is accessed.
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No error. I'd expect it to print null to the screen.

Why don't you try it out? It would be good practice.
 
mayank jamindar
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any More Suggestions.....
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(never mind)
[ January 26, 2006: Message edited by: Marc Peabody ]
 
Patrick Williams
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I haven't tried this, but wouldn't it print:

Name: AAA
Price: 0

???

I would assume that int would initialize to 0 because price is a class level member. Has anyone tried it?
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, yes. Patrick is correct. I did not see that price was an int - that's usually not the type you would use in the real world for price.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic