예제 #1
0
  protected void doGet(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {
    String pathInfo = req.getPathInfo();

    HttpSession session = req.getSession();
    if (session == null) {
      resp.setStatus(401);
      return;
    }
    String username = (String) session.getAttribute("username");
    if (username == null) {
      resp.setStatus(401);
      return;
    }

    Map userMap = loadUserSettingsMap(username);
    if (userMap == null) {
      resp.setStatus(401);
      return;
    }
    if (pathInfo.equals("/")) {
      resp.setContentType("application/json; charset=UTF-8");
      resp.getWriter().write(JSONUtil.write(userMap));
      return;
    }

    String key = pathInfo.substring(1);
    String value = (String) userMap.get(key);

    Map jsonObject = new HashMap();
    jsonObject.put(key, value);
    resp.setContentType("application/json; charset=UTF-8");
    resp.getWriter().write(JSONUtil.write(jsonObject));
  }
예제 #2
0
 /**
  * 输出json到HTML
  *
  * @param response
  * @param jsonString 要输出的字符串
  */
 public void outJson(HttpServletResponse response, String jsonString) {
   response.setContentType("text/html");
   response.setCharacterEncoding("utf-8");
   response.setHeader("Pragma", "no-cache");
   response.setHeader("Cache-Control", "no-cache, must-revalidate");
   response.setHeader("Pragma", "no-cache");
   try {
     response.getWriter().println(jsonString);
     response.getWriter().flush();
     response.getWriter().close();
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
 private void generateNoRowsPage(HttpServletResponse response) throws Exception {
   response.setContentType("text/html");
   response.getWriter().println("<html><head><title>");
   response.getWriter().println(XavaResources.getString("no_rows_report_message_title"));
   response
       .getWriter()
       .println(
           "</title></head><body style='font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;'>");
   response.getWriter().println("<h1 style='font-size:22px;'>");
   response.getWriter().println(XavaResources.getString("no_rows_report_message_title"));
   response.getWriter().println("</h1>");
   response.getWriter().println("<p style='font-size:16px;'>");
   response.getWriter().println(XavaResources.getString("no_rows_report_message_detail"));
   response.getWriter().println("</p></body></html>");
 }
  public void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    try {

      response.setContentType("text/html");
      PrintWriter out = response.getWriter();

      /*String n=request.getParameter("username");
      out.print("Welcome "+n);*/

      String name = request.getParameter("name");
      String dob = request.getParameter("dob");
      String address = request.getParameter("address");
      String email = request.getParameter("email");
      HttpSession session = request.getSession(true);
      String userid = (String) session.getAttribute("theName");
      int AccNo = 0;
      String AccMsg = "";

      DbCommunication db_comm = new DbCommunication();
      AccNo = db_comm.accountCreation(name, dob, address, email, userid);
      // db_comm.accountCreation(name,email);
      AccMsg = "Account created successfully. Account number is:" + AccNo;
      // out.println(AccMsg);

      String redirectURL = "accountCreationPage.jsp";
      response.sendRedirect(redirectURL);
      session.setAttribute("AccCreationalMsgStatus", "set");
      session.setAttribute("AccCreationalMsg", AccMsg);

    } catch (Exception e) {
      System.out.println(e);
    }
  }
예제 #5
0
  public void doGet(HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException {

    res.setContentType("text/html");
    PrintWriter out = res.getWriter();
    Enumeration values = req.getParameterNames();
    String name = "";
    String value = "";
    String id = "";
    while (values.hasMoreElements()) {
      name = ((String) values.nextElement()).trim();
      value = req.getParameter(name).trim();
      if (name.equals("id")) id = value;
    }
    if (url.equals("")) {
      url = getServletContext().getInitParameter("url");
      cas_url = getServletContext().getInitParameter("cas_url");
    }
    HttpSession session = null;
    session = req.getSession(false);
    if (session != null) {
      session.invalidate();
    }
    res.sendRedirect(cas_url);
    return;
  }
예제 #6
0
 public void doGet(HttpServletRequest request, HttpServletResponse response)
     throws ServletException, IOException {
   response.setContentType("text/html");
   PrintWriter out = response.getWriter();
   String title = "Showing Request Headers";
   StringBuilder sb = new StringBuilder();
   sb.append("<html>\n<head>\n");
   sb.append("<title>" + title + "</title>\n");
   sb.append("</head>\n");
   sb.append("<body bgcolor='#FDF5E6'>\n");
   sb.append("<h1 align='center'>" + title + "</h1>\n");
   sb.append("<b> Request Method: </b>" + request.getMethod() + "<br>\n");
   sb.append("<b> Request URI: </b>" + request.getRequestURI() + "<br>\n");
   sb.append("<b> Request Protocol: </b>" + request.getProtocol() + "<br>\n");
   sb.append("<table border=1 align='center'>\n");
   sb.append("<tr bgcolor='#FFAD00'>\n");
   sb.append("<th> Header Name </th><th> Header Value </th></tr>\n");
   Enumeration headerNames = request.getHeaderNames();
   while (headerNames.hasMoreElements()) {
     String headerName = (String) headerNames.nextElement();
     sb.append("<tr><td>" + headerName + "</td>");
     sb.append("<td>" + request.getHeader(headerName) + "</td></tr>\n");
   }
   sb.append("</table>\n");
   sb.append("</body></html>");
   out.println(sb.toString());
   out.close();
 }
예제 #7
0
  public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    String title = "Reading All Request Parameters";
    out.println(
        ServletUtilities.headWithTitle(title)
            + "<BODY BGCOLOR=\"#FDF5E6\">\n"
            + "<H1 ALIGN=CENTER>"
            + title
            + "</H1>\n"
            + "<TABLE BORDER=1 ALIGN=CENTER>\n"
            + "<TR BGCOLOR=\"#FFAD00\">\n"
            + "<TH>Parameter Name<TH>Parameter Value(s)");
    Enumeration paramNames = request.getParameterNames();
    while (paramNames.hasMoreElements()) {
      String paramName = (String) paramNames.nextElement();
      out.println("<TR><TD>" + paramName + "\n<TD>");
      String[] paramValues = request.getParameterValues(paramName);
      if (paramValues.length == 1) {
        String paramValue = paramValues[0];
        if (paramValue.length() == 0) out.print("<I>No Value</I>");
        else out.print(paramValue);
      } else {
        out.println("<UL>");
        for (int i = 0; i < paramValues.length; i++) {
          out.println("<LI>" + paramValues[i]);
        }
        out.println("</UL>");
      }
    }
    out.println("</TABLE>\n</BODY></HTML>");
  }
예제 #8
0
  public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    String title = "Session Tracking Example";
    HttpSession session = request.getSession(true);
    String heading;

    Integer accessCount = (Integer) session.getAttribute("accessCount");

    if (accessCount == null) {
      accessCount = new Integer(0);
      heading = "Welcome, Newcomer";
    } else {
      heading = "Welcome Back";
      accessCount = new Integer(accessCount.intValue() + 1);
    }

    session.setAttribute("accessCount", accessCount);
    out.println(
        "<BODY BGCOLOR=\"#FDF5E6\">\n"
            + "<H1 ALIGN=\"CENTER\">"
            + heading
            + "</H1>\n"
            + "<H2>Information on Your Session:</H2>\n"
            + "<TABLE BORDER=1 ALIGN=\"CENTER\">\n"
            + "<TR BGCOLOR=\"#FFAD00\">\n"
            + "  <TH>Info Type<TH>Value\n"
            + "<TR>\n"
            + "  <TD>ID\n"
            + "  <TD>"
            + session.getId()
            + "\n"
            + "<TR>\n"
            + "  <TD>Creation Time\n"
            + "  <TD>"
            + new Date(session.getCreationTime())
            + "\n"
            + "<TR>\n"
            + "  <TD>Time of Last Access\n"
            + "  <TD>"
            + new Date(session.getLastAccessedTime())
            + "\n"
            + "<TR>\n"
            + "  <TD>Number of Previous Accesses\n"
            + "  <TD>"
            + accessCount
            + "\n"
            + "</TR>"
            + "</TABLE>\n");

    // the following two statements show how to retrieve parameters in
    // the request.  The URL format is something like:
    // http://localhost:8080/project2/servlet/ShowSession?myname=Chen%20Li
    String myname = request.getParameter("myname");
    if (myname != null) out.println("Hey " + myname + "<br><br>");

    out.println("</BODY></HTML>");
  }
예제 #9
0
  public void doPost(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {

    resp.setContentType("text/html");
    PrintWriter out = resp.getWriter();

    String support = "support"; // valid username

    HttpSession session = null;
    session = req.getSession(false); // Get user's session object (no new one)
    if (session == null) {

      invalidUser(out); // Intruder - reject
      return;
    }

    String userName = (String) session.getAttribute("user"); // get username

    if (!userName.equals(support)) {

      invalidUser(out); // Intruder - reject
      return;
    }

    String action = "";
    if (req.getParameter("todo") != null) action = req.getParameter("todo");

    if (action.equals("update")) {

      doUpdate(out);
      return;
    }

    out.println("<p>Nothing to do.</p>todo=" + action);
  }
예제 #10
0
  public void doGet(HttpServletRequest req, HttpServletResponse res)
      throws IOException, ServletException {
    res.setContentType("text/html");
    try {
      PrintWriter pw = res.getWriter();
      pw.println("<html><head><TITLE>Web-Enabled Automated Manufacturing System</TITLE></head>");
      pw.println(
          "<body><br><br><br><form name=modifyuser method=post action='http://peers:8080/servlet/showUser')");
      v = U.allUsers();
      pw.println("<table align='center' border=0> <tr><td>");
      pw.println(
          "Select User Name To Modify</td><td><SELECT id=select1 name=uid style='HEIGHT: 22px; LEFT: 74px; TOP: 222px; WIDTH: 155px'>");
      pw.println("<OPTION selected value=''></OPTION>");
      for (i = 0; i < v.size(); i++)
        pw.println(
            "<OPTION value="
                + (String) v.elementAt(i)
                + ">"
                + (String) v.elementAt(i)
                + "</OPTION>");
      pw.println(
          "</SELECT></td></tr><tr><td></td><td><input type='submit' name='submit' value='Submit'></td></tr></table></form></body></html>");
      pw.flush();
      pw.close();

    } catch (Exception e) {
    }
  }
예제 #11
0
  public void doGet(HttpServletRequest rq, HttpServletResponse rs) {
    PrintWriter pw = null;
    try {
      pw = rs.getWriter();
      rs.setContentType("application/json");
      OperatorBLInterface operatorInterface = new Operator();
      LoyaltyApplication loyaltyApplication = new LoyaltyApplication();
      boolean found = loyaltyApplication.operatorExists(Integer.parseInt(rq.getParameter("code")));

      pw.println("{");
      pw.println("\"success\":true,");
      pw.println("\"found\":" + found);

      pw.println("}");
    } catch (ApplicationException ae) {
      System.out.println(ae);

      pw.println("{");
      pw.println("\"success\":false,");
      pw.println("\"errorMessage\":" + "\"" + ae + "\"");
      pw.println("}");
    } catch (Exception e) {
      System.out.println(e);
    }
  }
예제 #12
0
  public void doGet(HttpServletRequest rq, HttpServletResponse rs) {
    PrintWriter pw = null;
    try {
      pw = rs.getWriter();
      rs.setContentType("application/json");
      LoyaltyApplication loyaltyApplication = new LoyaltyApplication();
      loyaltyApplication.removeOperator(Integer.parseInt(rq.getParameter("code")));
      pw.println("{");
      pw.println("\"success\":true,");
      pw.println("\"message\":\"removed\"");
      pw.println("}");

    } catch (ApplicationException ae) {

      System.out.println(ae);

      pw.println("{");
      pw.println("\"success\":false,");
      pw.println("\"errorMessage\":" + "\"" + ae + "\"");
      pw.println("}");

    } catch (IOException ioe) {
      System.out.println(ioe);
    }
  }
예제 #13
0
 private void sendResponse(HttpServletResponse pResp, String pContentType, String pJsonTxt)
     throws IOException {
   setContentType(pResp, pContentType);
   pResp.setStatus(200);
   setNoCacheHeaders(pResp);
   PrintWriter writer = pResp.getWriter();
   writer.write(pJsonTxt);
 }
예제 #14
0
  public void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();

    System.out.println("queryString: " + request.getQueryString());
    out.println("FILTER-QUERYSTRING:" + (request.getQueryString() != null ? "PASS" : "FAIL"));
  }
예제 #15
0
  /**
   * 打印支持JSONP格式的结果
   *
   * @param response
   * @param restRequest
   * @param restResponse
   * @throws java.io.IOException
   */
  public static void printJsonForJsonp(
      HttpServletResponse response, RestRequest restRequest, RestResponse restResponse)
      throws IOException {

    PrintWriter out = response.getWriter();
    String jsonString = JSON.toJSONString(restResponse);
    response.setContentType("text/javascript; charset=UTF-8");
    out.print(restRequest.getCallback() + "(" + jsonString + ")");
  }
예제 #16
0
 public void doGet(HttpServletRequest request, HttpServletResponse response)
     throws ServletException, IOException {
   PrintWriter out = response.getWriter();
   out.println("<h1>Hello!! MyServlet says it is *** GET request.");
   System.out.println("[MyServlet] responding to *** GET request.");
   logger.info("Just some sample INFO messages");
   logger.debug("Just some sample DEBUG messages");
   logger.error("Just some sample ERROR messages");
 }
예제 #17
0
 // Called when a servlet doesn't get the parameters it expects/needs
 protected void paramError() throws IOException {
   // FIXME: As of 2006-03-15 this method and its only caller checkParam() are not called from
   // anywhere
   PrintWriter wrtr = resp.getWriter();
   Page page = new Page();
   // add referer, params, msg to contact lockss unless from old bookmark
   // or manually entered url
   page.add("Parameter error");
   page.write(wrtr);
 }
예제 #18
0
 /** Display a message in lieu of the normal page */
 protected void displayMsgInLieuOfPage(String msg) throws IOException {
   // TODO: Look at HTML
   Page page = newPage();
   Composite warning = new Composite();
   warning.add(msg);
   warning.add("<br>");
   page.add(warning);
   layoutFooter(page);
   page.write(resp.getWriter());
 }
  public void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    /*
     * // Create path components to save the file final String path =
     * request.getParameter("destination"); final Part filePart =
     * request.getPart("file"); final String fileName =
     * getFileName(filePart);
     */

    String path = request.getContextPath();
    String csvFileToRead = request.getRealPath("/") + "mail.csv";
    BufferedReader br = null;
    String line = "";
    String splitBy = ",";

    JSONArray jArrayMails = new JSONArray();
    try {
      br = new BufferedReader(new FileReader(csvFileToRead));
      while ((line = br.readLine()) != null) {
        jArrayMails.add(line);
      }
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    } finally {
      if (br != null) {
        try {
          br.close();
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
    }

    response.setContentType("application/json");
    PrintWriter out = response.getWriter();
    JSONObject jobj = new JSONObject();
    jobj.put("studentEmailsArray", jArrayMails);
    out.print(jobj);
  }
예제 #20
0
  public void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    System.out.println("[Servlet3.doPost]");

    response.setContentType("text/html");
    PrintWriter out = response.getWriter();

    out.println("FILTER-REQUEST:" + request.getSession().getAttribute("FILTER-REQUEST"));
    out.println("FILTER-FORWARD:" + request.getSession().getAttribute("FILTER-FORWARD"));
    out.println("FILTER-INCLUDE:" + request.getSession().getAttribute("FILTER"));
  }
예제 #21
0
파일: MLJAM.java 프로젝트: paxtonhare/mljam
 private static void sendServerProblemResponse(HttpServletResponse res, String s)
     throws IOException {
   // Commenting out the status code because we want the client to eval the error() call
   // res.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
   res.setContentType("x-marklogic/xquery; charset=UTF-8");
   if (s != null && s.length() > 4096) { // Cap super long errors
     s = s.substring(0, 2048) + " ...[trimmed]... " + s.substring(s.length() - 2048);
   }
   Writer writer = res.getWriter();
   writer.write("error('" + escapeSingleQuotes(s) + "')");
   writer.flush();
 }
예제 #22
0
  /**
   * Process incoming HTTP POST requests
   *
   * @param request Object that encapsulates the request to the servlet
   * @param response Object that encapsulates the response from the servlet
   */
  public void performTask(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    try {
      String service = getServiceName(request);
      PrintWriter out = null;
      out = response.getWriter();
      out.write(res.getString(service));
      out.flush();
      out.close();
    } catch (Throwable t) {
    }
  }
예제 #23
0
  public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws IOException, ServletException {
    prevURL = request.getParameter("url");
    String params = prevURL.replaceFirst(".*[?]", "");
    String[] paramsSplit = params.split("&");
    query = paramsSplit[0].replaceFirst(".*=", "");
    query = query.replaceAll("[+]", " ");

    response.setContentType("text/html");
    PrintWriter out = response.getWriter();

    this.printForm(out);
  }
예제 #24
0
 @Override // !!! note that this gets called for missing pages, but not if exceptions are thrown;
           // exceptions are handled separately
 public void handle(
     String target,
     Request request,
     HttpServletRequest httpServletRequest,
     HttpServletResponse httpServletResponse)
     throws IOException {
   request.setHandled(true);
   httpServletResponse
       .getWriter()
       .println(
           String.format("<h1>Page doesn't exist: %s</h1>", request.getUri().getDecodedPath()));
 }
예제 #25
0
  public void doGet(HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException {
    res.setContentType("text/html");
    PrintWriter toClient = res.getWriter();
    toClient.println("<!DOCTYPE HTML>");
    toClient.println("<html>");
    toClient.println("<head><title>Books</title></head>");
    toClient.println("<body>");
    toClient.println("<a href=\"index.html\">Home</A>");
    toClient.println("<h2>List of books</h2>");

    HttpSession session = req.getSession(false);
    if (session != null) {
      String name = (String) session.getAttribute("name");
      if (name != null) {
        toClient.println("<h2>name: " + name + "</h2>");
      }
    }

    toClient.print("<form action=\"bookOpinion\" method=GET>");
    toClient.println("<table border='1'>");

    String sql = "Select code, title, author FROM books";
    System.out.println(sql);
    try {
      Statement statement = connection.createStatement();
      ResultSet result = statement.executeQuery(sql);
      while (result.next()) {
        toClient.println("<tr>");
        String codeStr = result.getString("code");
        toClient.println(
            "<td><input type=\"radio\" name=\"book" + "\" value=\"" + codeStr + "\"></td>");
        toClient.println("<td>" + codeStr + "</td>");
        toClient.println("<td>" + result.getString("title") + "</td>");
        toClient.println("<td>" + result.getString("author") + "</td>");
        toClient.println("</tr>");
      }
    } catch (SQLException e) {
      e.printStackTrace();
      System.out.println("Resulset: " + sql + " Exception: " + e);
    }
    toClient.println("</table>");
    toClient.println("<textarea rows=\"8\" cols=\"60\" name=\"comment\"></textarea><BR>");
    toClient.println("<input type=submit>");
    toClient.println("</form>");
    toClient.println("</body>");
    toClient.println("</html>");
    toClient.close();
  }
예제 #26
0
 protected void writeResponse(
     final HttpServletResponse httpServletResponse,
     final SimpleStatusResponse simpleStatusResponse) {
   Gson gson = new Gson();
   try {
     httpServletResponse.setContentType("application/json; charset=utf-8");
     _log.debug("Serializing: " + simpleStatusResponse);
     final PrintWriter writer = httpServletResponse.getWriter();
     gson.toJson(simpleStatusResponse.getResponseStatus(), writer);
     writer.flush();
     writer.close();
   } catch (Exception e) {
     _log.error("Error while writing response: " + e.getMessage(), e);
   }
 }
예제 #27
0
  // ÖØŒ‘doGet()
  public void doGet(HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException {
    res.setContentType("text/html");
    PrintWriter pw = res.getWriter();

    pw.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">");
    pw.println("<head>");
    pw.println("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\">");
    pw.println("<!-- The Servlet expression tags interpolate script variables into the HTML -->");
    pw.println("<title>Hello, world!</title>");
    pw.println("</head>");
    pw.println("<body>");
    pw.println("<h1>Hello, world!</h1>");
    pw.println("</body>");
    pw.close();
  }
예제 #28
0
파일: P2B.java 프로젝트: otoro/cs143
 public void doGet(HttpServletRequest request, HttpServletResponse response)
     throws IOException, ServletException {
   response.setContentType("text/html");
   PrintWriter out = response.getWriter();
   out.println("<html>");
   out.println("<head>");
   String title = "Copycat Servlet";
   out.println("<title>" + title + "</title>");
   out.println("</head>");
   out.println("<body bgcolor=white>");
   out.println("<h1>" + title + "</h1>");
   String param = request.getParameter("menu");
   if (param != null) out.println("You requested " + param);
   out.println("</body>");
   out.println("</html>");
 }
예제 #29
0
  public void doGet(HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException {
    res.setContentType("text/html");
    PrintWriter out = res.getWriter();
    count++;
    out.println(
        "<h1>Since loading, this servlet instance has been accessed " + count + " times.</h1>");
    instances.put(this, this);
    out.println("<h2>There are currently " + instances.size() + " instances.</h2>");

    classCount++;
    out.println(
        "<h3>Across all instances, this servlet class has been accessed "
            + classCount
            + " times.</h3>");
  }
예제 #30
0
  public void service(HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException {
    res.setContentType("text/html");
    int cost;
    PrintWriter out = res.getWriter();
    System.out.println("CreditCard");

    HttpSession CCsession = req.getSession(true);
    cost = (Integer) CCsession.getValue("ba");

    Integer billamt = new Integer(cost);
    CCsession.putValue("ba", billamt);

    out.println("<html>");
    out.println("<title>CC..</title>");
    out.println("<body bgcolor=#737CA >");

    out.println("<form action=\"http://localhost:8080/servlet/CreditThanks\">");

    out.println("<font size=36 align=center color=#ffd7ff>");
    out.println("<center>Payment mode: Credit Card</center></font><br><br>");
    out.println("<br><br><br><br>");

    out.println("<font size=4>Enter your user id:");
    out.println("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
    out.println("&nbsp;&nbsp;&nbsp;");
    out.println("<input type=text name=\"userid\">");
    out.println("<br><br>Enter your Credit card no:");
    out.println("&nbsp;&nbsp;&nbsp;&nbsp;");
    out.println("<input type=text name=\"cardno\"><br><br>");

    out.println("Enter your Bank name:");
    out.println("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
    out.println("<input type=text name=\"bankname\"><br><br>");

    out.println("Bill amount:</b>");
    out.println(
        "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");

    out.println("&nbsp;&nbsp;&nbsp;&nbsp;Rs. &nbsp;");
    out.println("<input type=text name=\"billamt\" value=" + cost + ">&nbsp;&nbsp;/-");
    out.println("</font><br><br><br><br>");

    out.println("<input type=submit value=\"submit\">");

    out.println("</form></body></html>");
  } // service