Chapter 7c: Servlets, JSP, HTTP Monitoring - PowerPoint PPT Presentation

1 / 12
About This Presentation
Title:

Chapter 7c: Servlets, JSP, HTTP Monitoring

Description:

Access JavaBeans with JSP Standard Actions. Access JavaBeans from scriptlets ... Chapter 3, iteration 2: Web1. HelloServlet. Chapter 7, iteration 7: IceHockeyWeb ... – PowerPoint PPT presentation

Number of Views:51
Avg rating:3.0/5.0
Slides: 13
Provided by: conest
Category:

less

Transcript and Presenter's Notes

Title: Chapter 7c: Servlets, JSP, HTTP Monitoring


1
Chapter 7cServlets, JSP, HTTP Monitoring
Reference Eclipse WTP
2
Objectives
  • Servlets
  • Details in separate slides
  • What are JavaBeans?
  • JavaBean Usage within JSPs
  • Access JavaBeans with JSP Standard Actions
  • Access JavaBeans from scriptlets
  • Monitoring HTTP Sessions

3
Servlets
  • Acts as the input controller
  • Generates dynamic output
  • Code Samples
  • Chapter 3, iteration 2 Web1
  • HelloServlet
  • Chapter 7, iteration 7 IceHockeyWeb
  • LoginServlet (validates user/password)
  • EditScoreServlet (save scores to object)
  • ScheduleServlet (with XML transformation)

4
What Are JavaBeans?
  • Javas software component model specification
  • Written in Java platform neutral
  • JavaBean Characteristics
  • Must have a default (zero-argument) constructor
  • Used when restoring JavaBean from a file
  • Must be serializable
  • Implements java.io.Serializable
  • Can save JavaBean to a file
  • Note Many non-visual JavaBeans do not conform to
    this requirement.
  • Private instance variables
  • Public features (methods, properties, events)

5
JavaBean Property Types
  • Simple
  • Use standard getter/setter signatures
  • E.g., public String getName()
  • Boolean
  • Use isltPropertyNamegt for getter method
  • E.g., public boolean isValid()
  • Indexed
  • Represents an array of values
  • Use java.util.ArrayList for dynamic arrays
  • E.g., public ArrayList getValues()

6
Coding a JavaBean
  • Reference Page 281
  • Eclipse WTP
  • Use wizard to create getter/setter methods
  • E.g., User.java
  • Add instance variable(s)
  • private boolean loggedIn false
  • private String userId ""
  • Add getter/setter methods
  • public boolean isLoggedIn() return loggedIn
  • public void setLoggedIn(boolean loggedIn)
    this.loggedIn loggedIn

7
JavaBean as Data Transfer Objects
  • JavaBeans carry data between pages
  • Between business logic and presentation layer.
  • E.g., logout.jsp
  • Creates User JavaBean instance named user
  • ltjspuseBean class"com.leagueplanet.User"
    id"user" scope"session" /gt
  • Access user property values
  • Using JSP Action ltjspgetProperty name"user"
    property"userId" /gt
  • Using Scriptlet lt user.getUserId() gt

8
JavaBean, JSP Servlets
  • Chapter 7, iteration 7 IceHockeyWeb
  • Run login.jsp

9
Eclipse WTP Monitoring HTTP Sessions
  • Monitor LoginServlets HTTP traffic
  • Pages 289 - 293
  • Tomcat 6.x Server
  • Monitoring Properties

10
Eclipse WTP HTTP Port to Monitor
  • Add and start monitoring HTTP Port
  • Note WTP may change port to listen (from 8081 to
    14163)

11
Run JSP/Servlet Using Monitored HTTP Port
  • URL http//localhost14163/IceHockeyWeb/login.jsp
  • To display Window Show View Debug TCP/IP
    Monitor

12
Next Steps
  • Chapter 7
  • Iterations 6 8
  • Assignment 2
Write a Comment
User Comments (0)
About PowerShow.com