Thread: Pls Help
View Single Post
  #1 (permalink)  
Old 11-20-2007, 04:43 AM
vhannierose vhannierose is offline
Member
 
Join Date: Nov 2007
Location: taguig city, philippines
Posts: 4
vhannierose is on a distinguished road
Send a message via AIM to vhannierose Send a message via Yahoo to vhannierose
Pls Help
Hi! I'm currently having my J2EE training and I need help with this. Thanks in advance.

1.) Create a project in Eclipse. Name it ServletActivity 3 – Shopping Cart Application.

2.) Create a servlet (name it LoginServlet.java). This servlet outputs html code to the browser. The output should be a simple login page (See Screenshot 1). The servlet should retrieve the last login username from the cookies. If a user has logged-in before, display the username (See Screenshot 2), otherwise, display an empty username field.

3.) Create another servlet and name it DoLoginServlet.java. This servlet is called after clicking “Submit” button in LoginServlet.java. If the user inputs an empty username or an empty password, display an error message (See Screenshot 3). Otherwise, display the available items for sale (See Screenshot 4). In this servlet, place the username in the session. Also, create a cookie object and place it in the response. By placing the username inside a cookie, you can now keep track of the last username who have logged-in in the application per browser. Also, by placing the username inside the session, the next servlets can now authenticate users who have logged-in.

4.) Create another servlet and name it DoPurchaseServlet.java. This servlet checks the last action from DoLoginServlet.java, either the user submitted his purchases (Submit) or has cancelled (Logout). If the user sumitted his purchase/s (Submit) display the items that the user has selected in Screenshot 4 and ask for his credit card number for the payment of his items (See Screenshot 5). If the user cancelled his purchases, redirect the user to LoginServlet.java thus display Screenshot 2. Also, check if there’s a user who is currently logged-in, otherwise, redirect the user to LoginServlet.java. Through this way users can’t directly jump to DoPurchaseServlet.java without logging in first.

5.) Create another servlet and name it DoPaymentServlet.java. Check also if the last action was Submit or Logout (from DoPurchaseServlet.java). If he chooses to Logout redirect him to LoginServlet.java. If he chooses to Submit, display a thank you page if he has submitted his credit card number (See Screenshot 6). Again, check if there’s a user who have currently logged-in in the application, if none, redirect him to LoginServlet.java.

6.) Configure the servlets in web.xml and deploy and test the application.
Reply With Quote
Sponsored Links