@RequestMapping(value = "/ViewReports", method = RequestMethod.POST)
  public String prs(
      ModelMap model,
      HttpServletRequest request,
      HttpServletResponse response,
      @Valid CompanyReports CompanyName,
      BindingResult result) {

    if (result.hasErrors()) {
      System.out.println("sa");
      model.addAttribute("up", "Please Check the Values Entered");
      model.addAttribute("StockSearchHelper", new stocksearchhelper());
      model.addAttribute("CompanyName", new CompanyReports());
      List<stock> x = stockServiceInterface.liststock("NASDAQ");
      List<stock> y = stockServiceInterface.liststock("NASDAQCOMPOSITE");
      List<stock> z = stockServiceInterface.liststock("DOWJONES");
      List<stock> a = stockServiceInterface.liststock("GOLD");
      List<stock> b = stockServiceInterface.liststock("SANDP");
      List<stock> c = stockServiceInterface.liststock("OIL");
      model.addAttribute("NASDAQ", x.get(0).getPrice());
      model.addAttribute("NASDAQCOMPOSITE", y.get(0).getPrice());
      model.addAttribute("DOWJONES", z.get(0).getPrice());
      model.addAttribute("GOLD", a.get(0).getPrice());
      model.addAttribute("SANDP", b.get(0).getPrice());
      model.addAttribute("OIL", c.get(0).getPrice());
      List<TopPerformers> opds1 = topPerformerServiceInterface.liststock();
      model.addAttribute("first", opds1.get(0).getTickerCode());
      model.addAttribute("second", opds1.get(1).getTickerCode());
      model.addAttribute("third", opds1.get(2).getTickerCode());
      model.addAttribute("fourth", opds1.get(3).getTickerCode());
      return "ClientHome";
    } else {

      System.out.println("saa");
      String cn = CompanyName.getCompanyName();

      // String
      // s="C:"+File.separator+"Users"+File.separator+"nisha"+File.separator+"Desktop"+File.separator+"New folder (6)"+File.separator+".metadata"+File.separator+".plugins"+File.separator+"org.eclipse.wst.server.core"+File.separator+"tmp1"+File.separator+"wtpwebapps"+File.separator+"Project"+File.separator+"images"+File.separator;

      String s = request.getRealPath("") + File.separator;

      String e = s + CompanyName.getCompanyName() + ".pdf";
      File files = new File(e);

      response.setContentType("application/pdf"); // in my example this was an xls file
      response.setContentLength(new Long(files.length()).intValue());
      response.setHeader("Content-Disposition", "attachment; filename=MyFile.pdf");

      try {
        FileCopyUtils.copy(new FileInputStream(files), response.getOutputStream());
      } catch (IOException es) {
        es.printStackTrace();
      }

      // return "redirect:/Client/viewmyaccount";

      return "redirect:/success";
    }
  }
  @RequestMapping(value = "/Regression", method = RequestMethod.POST)
  public String regression(
      ModelMap model,
      HttpServletRequest request,
      @Valid stocksearchhelper StockSearchHelper,
      BindingResult result)
      throws MalformedURLException, IOException {

    if (result.hasErrors()) {
      model.addAttribute("re", "Please Check the Values Entered");
      model.addAttribute("StockSearchHelper", new stocksearchhelper());
      model.addAttribute("CompanyName", new CompanyReports());
      List<stock> x = stockServiceInterface.liststock("NASDAQ");
      List<stock> y = stockServiceInterface.liststock("NASDAQCOMPOSITE");
      List<stock> z = stockServiceInterface.liststock("DOWJONES");
      List<stock> a = stockServiceInterface.liststock("GOLD");
      List<stock> b = stockServiceInterface.liststock("SANDP");
      List<stock> c = stockServiceInterface.liststock("OIL");
      model.addAttribute("NASDAQ", x.get(0).getPrice());
      model.addAttribute("NASDAQCOMPOSITE", y.get(0).getPrice());
      model.addAttribute("DOWJONES", z.get(0).getPrice());
      model.addAttribute("GOLD", a.get(0).getPrice());
      model.addAttribute("SANDP", b.get(0).getPrice());
      model.addAttribute("OIL", c.get(0).getPrice());
      List<TopPerformers> opds1 = topPerformerServiceInterface.liststock();
      model.addAttribute("first", opds1.get(0).getTickerCode());
      model.addAttribute("second", opds1.get(1).getTickerCode());
      model.addAttribute("third", opds1.get(2).getTickerCode());
      model.addAttribute("fourth", opds1.get(3).getTickerCode());
      return "ClientHome";
    } else {
      String symbol = StockSearchHelper.getName();
      statistics s = statisticServiceInterface.refreshStockInfo(symbol);
      // System.out.println("apple"+s.getRsquare());
      double[] x = s.getX();

      double[] y = new double[20];

      for (int i = 0; i < y.length; i++) {

        y[i] = x[i] / 10;
      }

      // Data data = Data.newData(y);

      Line line1 = Plots.newLine(Data.newData(y), Color.newColor("CA3D05"), "Trend");
      line1.setLineStyle(LineStyle.newLineStyle(3, 1, 0));
      line1.addShapeMarkers(Shape.DIAMOND, Color.newColor("CA3D05"), 12);
      line1.addShapeMarkers(Shape.DIAMOND, Color.WHITE, 8);

      LineChart chart = GCharts.newLineChart(line1);
      chart.setSize(600, 450);
      chart.setTitle("Market Trend|(in 100's)", Color.WHITE, 14);

      AxisLabels yAxis = AxisLabelsFactory.newAxisLabels("", "1", "2", "3", "4");
      AxisLabels xAxis3 = AxisLabelsFactory.newAxisLabels("Weeks", 25.0);
      xAxis3.setAxisStyle(AxisStyle.newAxisStyle(Color.WHITE, 14, AxisTextAlignment.CENTER));
      yAxis.setAxisStyle(AxisStyle.newAxisStyle(Color.WHITE, 14, AxisTextAlignment.CENTER));

      chart.setBackgroundFill(Fills.newSolidFill(Color.newColor("1F1D1D")));
      LinearGradientFill fill = Fills.newLinearGradientFill(0, Color.newColor("363433"), 100);
      fill.addColorAndOffset(Color.newColor("2E2B2A"), 0);
      chart.setAreaFill(fill);

      chart.addXAxisLabels(yAxis);
      chart.addXAxisLabels(xAxis3);

      String url = chart.toURLString();

      // Passing the chart to the JSP for rendering.
      model.addAttribute("url", chart.toURLString());
      model.addAttribute("Statistics", s);

      long currentTime = (new Date()).getTime();
      // long

      try {

        URL yahoofin =
            new URL("http://finance.yahoo.com/d/quotes.csv?s=" + symbol + "&f=e7e8e9r6r7&e=.csv");
        URLConnection yc = yahoofin.openConnection();
        BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
        String inputLine;
        while ((inputLine = in.readLine()) != null) {
          String[] yahooStockInfo = inputLine.split(",");

          model.addAttribute("epsestimatecurrentyear", Float.valueOf(yahooStockInfo[0]));
          model.addAttribute("epsestimatenextyear", Float.valueOf(yahooStockInfo[1]));
          model.addAttribute("epsestimatenextquarter", Float.valueOf(yahooStockInfo[2]));
          model.addAttribute("pricesestimatecurrentyear", Float.valueOf(yahooStockInfo[3]));
          model.addAttribute("priceestimatenextyear", Float.valueOf(yahooStockInfo[4]));

          break;
        }
        in.close();
        return "statisticanalysis";

      } catch (Exception ex) {

      }

      return "statisticanalysis";
    }
  }