• 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

java bean

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any More Suggestions.....
 
Marc Peabody
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
(never mind)
[ January 26, 2006: Message edited by: Marc Peabody ]
 
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic