Need help on creating code using cart The output has to show

Need help on creating code using cart. The output has to show multiple lines of the users information.

So far this is what I have:

index.html:

chapter8.jsp
<%@page contentType=\"text/html\" pageEncoding=\"UTF-8\"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">
        <title>JSP Page</title>
    </head>
    <body>
      <%@ page import=\"java.io.*, business.*, data.*, list.*\" %>
      <%
        // get parameters from the request
        String firstName = request.getParameter(\"firstName\");
        String lastName = request.getParameter(\"lastName\");
        String email = request.getParameter(\"email\");
        String phoneNumber = request.getParameter(\"phoneNumber\");
        // get a relative file name
       // ServletContext sc = this.getServletContext();
       // String path = sc.getRealPath(\"/WEB-INF/EmailList.txt\");

File tempdir = (File) this.getServletContext().getAttribute(\"javax.servlet.context.tempdir\");
String temppath = tempdir.toString();
String path = temppath + \"/EmailList.txt\";

        // use regular Java objects
        User1 user = new User1(firstName, lastName, email, phoneNumber);
        UserIO.add(user, path);
    %>
    <h1>Thanks for joining our email list</h1>

    <p>Here is the information that you entered:</p>

    <table cellspacing=\"5\" cellpadding=\"5\" border=\"1\">
        <tr>
            <th>First Name</th>
            <th>Last Name</th>
            <th>Email</th>
            <th>Phone Number</th>
        </tr>
        <tr>
            <td><%= user.getFirstName() %></td>
            <td><%= user.getLastName() %></td>
            <td><%= user.getEmailAddress() %></td>
            <td><%=user.getPhoneNumber() %></td>  
        </tr>
    </table>
    </body>
</html>

User1.java

package business;

public class User1
{
    private String firstName;
    private String lastName;
    private String email;
    private String phoneNumber;
    public User1()
    {
        firstName = \"\";
        lastName = \"\";
        email = \"\";
        phoneNumber = \"\";
    }
  
    public User1(String firstName, String lastName, String email, String phoneNumber)
    {
        this.firstName = firstName;
        this.lastName = lastName;
        this.email = email;
        this.phoneNumber = phoneNumber;
    }
  
    public void setFirstName(String firstName)
    {
        this.firstName = firstName;
    }

    public String getFirstName()
    {
        return firstName;
    }
  
    public void setLastName(String lastName)
    {
        this.lastName = lastName;
    }

    public String getLastName()
    {
        return lastName;
    }
  
    public void setEmailAddress(String email)
    {
        this.email = email;
    }

    public String getEmailAddress()
    {
        return email;
    }
    public void setPhoneNumber(String phoneNumber)
    {
       this.phoneNumber = phoneNumber;
    }
    public String getPhoneNumber()
    {
        return phoneNumber;
    }
}

UserIO.java

package data;

import java.io.IOException;
import java.io.PrintWriter;
import java.io.*;
import business.User1;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class UserIO extends HttpServlet {
public static void add(User1 user, String filepath) throws IOException
    {
        File file = new File(filepath);
        PrintWriter out = new PrintWriter(
                new FileWriter(file, true));
        out.println(user.getEmailAddress()+ \"|\"
                + user.getFirstName() + \"|\"
                + user.getLastName() + \"|\"
                + user.getPhoneNumber());      
        out.close();
    }
}

*NEED HELP!*
cart.java

package list;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


public class cart extends HttpServlet {

Solution

Ans:

Cart.java:

package list;
import business;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class cart extends HttpServlet {
public void doGet(HttpServletRequest request,HttpServletResponse response) throws ServeletException,IOException
   {
   PrintWriter out=response.getWriter();//creating printwriter object
   response.setContentType(\"text/html\");//setting mime type
File tempdir = (File)this.getServletContext().getAttribute(\"javax.servlet.context.tempdir\");
String temppath = tempdir.toString();
String path = temppath + \"/EmailList.txt\";
FileReader fr=new FileReader(path);//opening file read mode
BufferedReader br=new BufferedReader(fr);//to read text line by line
String temp;
out.println(\"<table border=3 align=\'center\'><tr><th colspan=4>Users Information</th></tr><tr><th>Emailid</th><th>FirstName</th><th>LastName</th><th>MobileNumber</th></tr>\");
while((temp=br.readLine())!=null)//reading text from file untill EOF has been reached
       {
String str[]=temp.split(\"|\");//spilt\'s string into 4 parts
           out.println(\"<tr>\");//opening table row
           for(int i=0;i<str.length;i++)
           {
out.println(\"<th>\"+str[i]+\"</th>\");//getting information
           }//end of for loop
           out.println(\"</tr>\");//end of table row
       }//end of while loop
       out.println(\"</table>\");
       out.close();
   }//end of doGet()
public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServeletException,IOException
   {
   doGet(request,response);//redirect to doGet()
   }//doPost

}//end of cart

Need help on creating code using cart. The output has to show multiple lines of the users information. So far this is what I have: index.html: chapter8.jsp <
Need help on creating code using cart. The output has to show multiple lines of the users information. So far this is what I have: index.html: chapter8.jsp <
Need help on creating code using cart. The output has to show multiple lines of the users information. So far this is what I have: index.html: chapter8.jsp <
Need help on creating code using cart. The output has to show multiple lines of the users information. So far this is what I have: index.html: chapter8.jsp <

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site