27
1 Web Programming with Servlets & JSP ASSIGNMENT GUIDELINE

Web Programming with Servlets & JSP ASSIGNMENT GUIDELINE

Embed Size (px)

DESCRIPTION

Web Programming with Servlets & JSP ASSIGNMENT GUIDELINE. Objectives. Assignment Guideline 9 Assignment Guideline 10 Assignment Guideline 11 Assignment Guideline 12 Assignment Guideline 13 Assignment Guideline 14 Assignment Guideline 15. Assignment Guideline 1 Assignment Guideline 2 - PowerPoint PPT Presentation

Citation preview

Page 1: Web Programming with Servlets & JSP ASSIGNMENT GUIDELINE

1

Web Programming with Servlets & JSPASSIGNMENT GUIDELINE

Page 2: Web Programming with Servlets & JSP ASSIGNMENT GUIDELINE

Objectives

Assignment Guideline 1 Assignment Guideline 2 Assignment Guideline 3 Assignment Guideline 4 Assignment Guideline 5 Assignment Guideline 6 Assignment Guideline 7 Assignment Guideline 8

2

Assignment Guideline 9 Assignment Guideline 10 Assignment Guideline 11 Assignment Guideline 12 Assignment Guideline 13 Assignment Guideline 14 Assignment Guideline 15

Page 3: Web Programming with Servlets & JSP ASSIGNMENT GUIDELINE

Assignment Guideline 1

3

Page 4: Web Programming with Servlets & JSP ASSIGNMENT GUIDELINE

Assignment Guideline 2

4

Using methods Remote Host: request.getRemoteHost() Remote Port: request.getRemotePort() Request URI: request.getRequestURI() Server name: request.getServerName() Server port: request.getServerPort()

Page 5: Web Programming with Servlets & JSP ASSIGNMENT GUIDELINE

Assignment Guideline 3 – 1

5

Building 2 servlets InputServlet includes the form and inputted controls DisplayServlet presents the inputted value

Page 6: Web Programming with Servlets & JSP ASSIGNMENT GUIDELINE

Assignment Guideline 3 – 2

6

301 (Moved Permanently) Requested document permanently moved elsewhere (indicated in

Location header). Browsers go to new location automatically

Hints: Using setStatus and setHeader as following

response.setStatus(301); response.setHeader( "Location",

"http://localhost:8084/AssM3/MovePermanently.html" );response.setHeader(“Connection”, “close”);

Using sendError with the same status code

Page 7: Web Programming with Servlets & JSP ASSIGNMENT GUIDELINE

Assignment Guideline 4 – 1

7

Building 2 servlets CookiesServlet includes

the form and inputted controls depending on the checking cookies result

WelcomeServlet checking the user in cookies to show welcome message and add the cookie if the new user is

Page 8: Web Programming with Servlets & JSP ASSIGNMENT GUIDELINE

Assignment Guideline 4 – 2

8

Building a servlet Session Tracking applies the HttpSession interface methods and

Session technologies to view above GUI

Page 9: Web Programming with Servlets & JSP ASSIGNMENT GUIDELINE

Assignment Guideline 5

9

Building html file same as the left above image Building 2 servlet

First Servlet Using the getParameter method of request object Then using the setAttribute and getRequestDispatch methods of

ServletContext Interface to store the parameter and forward the Second Servlet

Second Servlet: retrieve the object using the getAttribute method, then print it

Page 10: Web Programming with Servlets & JSP ASSIGNMENT GUIDELINE

Assignment Guideline 6_1

10

Building a servlet uses the “Basic” header and Base64Decoder to checking username and password from users

The results should be presented as above images

Page 11: Web Programming with Servlets & JSP ASSIGNMENT GUIDELINE

Assignment Guideline 6_2

11

Page 12: Web Programming with Servlets & JSP ASSIGNMENT GUIDELINE

Assignment Guideline 6_2 (cont)

12

Page 13: Web Programming with Servlets & JSP ASSIGNMENT GUIDELINE

Assignment Guideline 6_2 (cont)

13

Creating a html file with form including 3 text box (name, age, address), and a button Submit

Building a CheckingServlet uses validation the inputted informationDo not allow null with name and age fieldsThe age value must be a numeric and larger than 18The Welcome message will be present with the link transfer to the

protect resource (test.html in admin directory) Configuring the web deployment descriptor to the BASIC

authentication with role as manager, users The test.html file only present the message The results should be presented as above images

Page 14: Web Programming with Servlets & JSP ASSIGNMENT GUIDELINE

Assignment Guideline 7

14

Creating a index.jsp file present the current Date applying the Calendar and Date package of java.util library

Creating a second.jsp file includes the image control which gets the image from the images directory at your web page directory

Page 15: Web Programming with Servlets & JSP ASSIGNMENT GUIDELINE

Assignment Guideline 8_1

15

Creating a index.jsp file present header using (reference request object in chapter 2) request.getHeaderNames () request.getHeader() request.getHeaders

Page 16: Web Programming with Servlets & JSP ASSIGNMENT GUIDELINE

Assignment Guideline 8_2

16

Creating 02 index.jsp page First, the Login form with

action the process.jsp Second, the process.jsp file is

implemented the session mechanism with cookies same as the chapter 4

The results are similar to the above images

Page 17: Web Programming with Servlets & JSP ASSIGNMENT GUIDELINE

Assignment Guideline 9_1

17

Creating a JavaBean named AmountBean include the amount property with int data-type and the DISCOUNT is 30%

Creating includeForward.jsp file are the form with textbox and button, and applying the AmountBean to calculate the returned amount after the user submit

Creating the products.jsp file using jsp:include applying the includeForward.jsp file Creating the forward.jsp file using jsp:forward applying the products.jsp file. The forward.jsp

file is the default page of application

Page 18: Web Programming with Servlets & JSP ASSIGNMENT GUIDELINE

Assignment Guideline 9_2

18

Creating first.jsp file using request.setAttribute with value of “user” attribute is “Aptechie” and using jsp:forward to the second.jsp file

The second.jsp file uses jsp:include the lastPage.html file and present the value of “user” attribute to the browser

The lastPage.html presents the message This is the last page of this WebSite

The results of program should be same as the image

Page 19: Web Programming with Servlets & JSP ASSIGNMENT GUIDELINE

Assignment Guideline 10_1

19

Creating the JSP page usingThe Arithmetic OperationsThe Logic OperationsThe header – EL Implicit Object

with the “User-Agent” valueThe Result must be same as the

image

Page 20: Web Programming with Servlets & JSP ASSIGNMENT GUIDELINE

Assignment Guideline 10_2

20

Creating the JSP page usingThe param – EL Implicit Object to process the inputted valueApplying the addition series calculation for Total AmountThe Result must be same as the image

Page 21: Web Programming with Servlets & JSP ASSIGNMENT GUIDELINE

Assignment Guideline 11_1

21

Creating the JSP page usingDeclaring the String array with form of each elements as

productName:priceUsing c:forEach, c:forTokens, and c:out to traverse and print

each element of array as above image

Page 22: Web Programming with Servlets & JSP ASSIGNMENT GUIDELINE

Assignment Guideline 11_2

22

Creating the JSP page using Declaring the String array with form of each elements as

destinationName:price Building the form with a textbox and a button Using c:forEach, c:forTokens, c:if, c:set, and c:out to traverse, checking the

existing destination and print as above image

Page 23: Web Programming with Servlets & JSP ASSIGNMENT GUIDELINE

Assignment Guideline 12_1

23

Creating the I18N in Servlets as the above image using Servlets Should reference the steps in Workshop. However, convert the

reference code to the servlet

Page 24: Web Programming with Servlets & JSP ASSIGNMENT GUIDELINE

Assignment Guideline 12_2

24

Creating the JSP page using I18N and formatting Tag library to do the exercise (using format setLocale,

formatNumer and Decision making tag library to present the result)

Page 25: Web Programming with Servlets & JSP ASSIGNMENT GUIDELINE

Assignment Guideline 13

25

Do it again the workshop 3 of Chapter 13 in CD with construct

if Cond Then Else

Page 26: Web Programming with Servlets & JSP ASSIGNMENT GUIDELINE

Assignment Guideline 14

26

Do it again the workshop 2 of Chapter 13 in CD that creating the custom Tag with upper case all the body content using BodyTagSupport Class

Page 27: Web Programming with Servlets & JSP ASSIGNMENT GUIDELINE

Assignment Guideline 15

27

Building 03 tag files and a JSP file can do Upper case all the body content in tag The heading row with 6 columns (6 attributes) The column row with 5 inputted column, and the 6th column averaged from 3

last column and format as a images (using JSTL tag lib) The JSP file is contains the combination of 3 above tags same as the image