Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How JavaBeans in JSP Number guess game in Tomcat?  RSS feed

 
Bugra Cakir
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Could anyone point some books or say about how
javabeans are used in JSP for example in Tomcat
JSP examples(Number Guess Game) ?
How is it working ?
Bugra Cakir
 
Chris Baron
Ranch Hand
Posts: 1061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bugra,
there are 2 files you should have a look at:
The first one is <tomcat_dir>/webapps/examples/jsp/num/numguess.jsp. That's the file you see in the browser.
with:
<%@ page import = "num.NumberGuessBean" %>
the bean is imported. This bean resides in the second relevant file.
That's NumberGuessBean.class. To see it's sourcecode open
<tomcat_dir>/webapps/examples/WEB-INF/classes/num/NumberGuessBean.java
in your editor
Back to the jsp. With:
<jsp:useBean id="numguess" class="num.NumberGuessBean" scope="session"/>
a NumberGuessBean-Object with the name numguess is created:
Via the name the Object's public methods can be used. E.g.:
numguess.getSuccess()
hth cb
[ August 07, 2003: Message edited by: Chris Baron ]
 
Bugra Cakir
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for those explanations but I don't understand the other part
about form get method because every time the user give a number
numguess.jsp?guess=30 for example, i can't see the usage of guess
get parameter. Where is it used ?
Bugra
 
Chris Baron
Ranch Hand
Posts: 1061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://developer.java.sun.com/developer/qow/archive/100/
<jsp:setProperty name="numguess" property="*"/>
calls setGuess()
Didn't know that Thanks for your question
cb
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!