title: JSP Servlet to retrieve(display) web pages
body: <p>I am writing a servlet in JSP page to display the requested webpage. I have done fair bit of "googling" and most of them suggested of using BufferedReader. Below I have the code that gets the requested url from the JSP page and the servlet displays the page.</p>
  
  <p>However, while running this I am getting blank from the servlet. Could anyone suggest me what wrong I have been doing in this code?</p>
  
  <pre><code>protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  
          String server = request.getParameter("browsebox");
  
          URL url = new URL(server);
          URLConnection yc = url.openConnection();
          BufferedReader in = new BufferedReader(new InputStreamReader(
                  yc.getInputStream(), "UTF-8"));
          String inputLine;
          StringBuilder a = new StringBuilder();
          while ((inputLine = in.readLine()) != null)
              a.append(inputLine);
          in.close();
  
         PrintWriter out = response.getWriter();
          out.println(a);
          // String output= a.toString();
          //System.out.println(output);
      }
  </code></pre>