/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package twitservlets;
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;
import model.LatestTweets;

/**
 *
 * @author user
 */
public class getlatesttweets extends HttpServlet {

    /**
     * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
     * methods.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        try (PrintWriter out = response.getWriter()) {
            /* TODO output your page here. You may use following sample code. */
            String query=request.getParameter("query");
           Object trend=LatestTweets.returnTweets(query);
                   //     System.out.println(trend);

            //out.println("ashutosh");
            out.print(trend);
           // Twitter twitter = TwitterFactory.getSingleton();
    //Query query = new Query("source:twitter4j yusukey");
    //QueryResult result = twitter.search(query);
   // for (Status status : result.getTweets()) {
     //   System.out.println("@" + status.getUser().getScreenName() + ":" + status.getText());
    //}
        }
    }

    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /**
     * Handles the HTTP <code>GET</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    /**
     * Handles the HTTP <code>POST</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    /**
     * Returns a short description of the servlet.
     *
     * @return a String containing servlet description
     */
    @Override
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>

}

@@ -1,192 +1,4 @@
-/*%0D%0A * To change this license header, choose License Headers in Project Properties.%0D%0A * To change this template file, choose Tools %7C Templates%0D%0A * and open the template in the editor.%0D%0A */
 %0D%0Apa
@@ -285,37 +285,8 @@
 %0D%0A%0D%0A
-/**%0D%0A *%0D%0A * @author user%0D%0A */
 %0D%0Apu
@@ -343,326 +343,8 @@
 %0D%0A  
-  /**%0D%0A     * Processes requests for both HTTP %3Ccode%3EGET%3C/code%3E and %3Ccode%3EPOST%3C/code%3E%0D%0A     * methods.%0D%0A     *%0D%0A     * @param request servlet request%0D%0A     * @param response servlet response%0D%0A     * @throws ServletException if a servlet-specific error occurs%0D%0A     * @throws IOException if an I/O error occurs%0D%0A     */
 %0D%0A  
@@ -823,1345 +823,301 @@
     
- //     System.out.println(trend);%0D%0A%0D%0A            //out.println(%22ashutosh%22);%0D%0A            out.print(trend);%0D%0A           // Twitter twitter = TwitterFactory.getSingleton();%0D%0A    //Query query = new Query(%22source:twitter4j yusukey%22);%0D%0A    //QueryResult result = twitter.search(query);%0D%0A   // for (Status status : result.getTweets()) %7B%0D%0A     //   System.out.println(%22@%22 + status.getUser().getScreenName() + %22:%22 + status.getText());%0D%0A    //%7D%0D%0A        %7D%0D%0A    %7D%0D%0A%0D%0A    // %3Ceditor-fold defaultstate=%22collapsed%22 desc=%22HttpServlet methods. Click on the + sign on the left to edit the code.%22%3E%0D%0A    /**%0D%0A     * Handles the HTTP %3Ccode%3EGET%3C/code%3E method.%0D%0A     *%0D%0A     * @param request servlet request%0D%0A     * @param response servlet response%0D%0A     * @throws ServletException if a servlet-specific error occurs%0D%0A     * @throws IOException if an I/O error occurs%0D%0A     */%0D%0A    @Override%0D%0A    protected void doGet(HttpServletRequest request, HttpServletResponse response)%0D%0A            throws ServletException, IOException %7B%0D%0A        processRequest(request, response);%0D%0A    %7D%0D%0A%0D%0A    /**%0D%0A     * Handles the HTTP %3Ccode%3EPOST%3C/code%3E method.%0D%0A     *%0D%0A     * @param request servlet request%0D%0A     * @param response servlet response%0D%0A     * @throws ServletException if a servlet-specific error occurs%0D%0A     * @throws IOException if an I/O error occurs%0D%0A     */
+%0D%0A%0D%0A           %0D%0A            out.print(trend);%0D%0A          %0D%0A        %7D%0D%0A    %7D%0D%0A%0D%0A    %0D%0A    @Override%0D%0A    protected void doGet(HttpServletRequest request, HttpServletResponse response)%0D%0A            throws ServletException, IOException %7B%0D%0A        processRequest(request, response);%0D%0A    %7D%0D%0A%0D%0A   
 %0D%0A  
@@ -1327,136 +1327,8 @@
     
-/**%0D%0A     * Returns a short description of the servlet.%0D%0A     *%0D%0A     * @return a String containing servlet description%0D%0A     */
 %0D%0A  
@@ -1424,25 +1424,8 @@
    %7D
-// %3C/editor-fold%3E
 %0D%0A%0D%0A

Update getlatesttweets.java