QuestionQuestion

Create following Shopping site with only Servlets.
1. Your site should start from CyberShopping.java servlet which does following:
(3) Your site only works for IE (check word "Trident" for IE or not). If not, show error page using HTML standard error code "HttpServletResponse.SC_HTTP_VERSION_NOT_SUPPORTED" and your message "Only Microsoft IE browser is working for this site."
(7) Check if user is first time visitor by checking the cookie "Visit" yer or no. if new visitor, set " Visit " cookie with yes for one year and move user to StartMyShopping.java servlet.
(5) The header of StartMyShopping.java should say "Welcome New Visitor" when if user is new visitor. Otherwise, just "Welcome Back".

2. (10) From StartMyShopping.java, does following: This page has one shopping item text box that user can type any item but blank with "Add to Shopping List" button to add to shopping list (shoppingList.java).
If user types blank and submit "Add" button, system should show same page with error message "Please enter shopping item." next to the shopping item text box.

3. (10) From shoppingList.java, it just shows all shopping list you added so far in list format. And, at the end, you have a link to go back "Keep Shopping" to StartMyShopping.java. All shopping items must be stored in a session value. So, whenever you add new item from StartMyShopping.java page, your list keeps previous items in list and just add new one.
Shopping list.html
<HTML>
<HEAD>
<TITLE>Shopping List</TITLE>
</HEAD>
<BODY>
<CENTER>
<H1>Shopping List</H1>
<UL>
<LI>List 1</LI>
<LI>List 2</LI>
<LI>List 3</LI>
</UL>
<br><a href="StartMyShopping">Keep Shopping >></a><br><br>
</CENTER>
</BODY></HTML>
ShartmyShopping.html
<HTML>
<HEAD>
<TITLE>Order Form</TITLE>
</HEAD>
<BODY>
<CENTER>
<H1>Welcome Back</H1>
<FORM ACTION="shoppingList" METHOD="POST">
<TABLE BORDER=1 CELLPADDING=5 CELLSPACING=0>
<TR>
<TD>Shopping Item:</TD>
<TD><INPUT TYPE="TEXT" NAME="Item" maxlength="20" size="25">
</TD>
</TR>
</TABLE>
<br><BUTTON TYPE="SUBMIT" NAME="AddBtn" VALUE="AddBtn" size=80>Add to Shopping List</BUTTON>
</FORM>
</CENTER></BODY></HTML>

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

package servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
* Servlet implementation class ShoppingList
*/
@WebServlet("/shoppingList")
public class ShoppingList extends HttpServlet {
private static final long serialVersionUID = 1L;

private ArrayList<String> lstItems;
      
    /**
    * @see HttpServlet#HttpServlet()
    */
    public ShoppingList() {
       super();
       // TODO Auto-generated constructor stub
       lstItems = new ArrayList<String>();
    }

/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
String error = (String) request.getAttribute("error");
if(error != null && !error.trim().equals("")) {
RequestDispatcher dispather = request.getRequestDispatcher("StartMyShopping");
dispather.forward(request,response);
} else {
String item = (String) request.getAttribute("item");

lstItems.add(item);

String lst = "<HTML>\n" +
"\n" +
"<HEAD>\n" +
"\n" +
"<TITLE>Shopping List</TITLE>\n" +
"\n" +
"</HEAD>\n" +
"\n" +
"<BODY>\n" +
"\n" +
"<CENTER>\n" +
"\n" +
"<H1>Shopping List</H1>\n" +
"\n" +
"<UL>\n" +
"\n";

for (String itm: lstItems...

By purchasing this solution you'll be able to access the following files:
Solution.zip.

50% discount

Hours
Minutes
Seconds
$50.00 $25.00
for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Web Development (HTML, XML, PHP, JavaScript, Adobe, Flash, etc.) Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats