i have a `post method to servlet`,so servlet return a web page after forwarding a request to another page  
 `getServletContext().getRequestDispatcher("/AnotherServlet").forward(request, response);`  

so i can't redirect directly `window.location ="/Anotherservlet"`   
 i tried many solution: passing parameters with links and it is working but i'would a better one  
i tried `var w = window.open(); w.document.write(data);` and it is working but the url of the page still my home page and the page still loading even the page is downloaded from server(all function with ready statement not working) so when i click in button with href="#" it redirect me to home page because as i said before my URL=/ not =/anotherservlet  
i don't like get method to do that or cookies for that i search for other solution thanks for help  

this is my servlet :

```
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    String name= request.getParameter("name");
    String pass=request.getParameter("pass");

     if (name.equals("a")&&pass.equals("0cc175b9c0f1b6a831c399e269772661"))
    {
    getServletContext().getRequestDispatcher("/BookListServlet").forward(request, response);
    }
    else 
    {
     response.setContentType("text/plain");
        PrintWriter out = response.getWriter();
        out.print("error");
        out.flush();
        out.close();
    }

}

```

this is my BookListServlet:  

```
 protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    books= new bookiml().get_books();   
    String name= request.getParameter("name");
    String ipAddress = request.getRemoteAddr();

request.setAttribute("books", books);
request.setAttribute("userip", ipAddress);
request.setAttribute("user", name);
request.setAttribute("title", "Book listing");

getServletContext().getRequestDispatcher("/META-INF/pages/book-list.jsp").forward(request, response);
}

/**
 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
 */
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub
    doGet(request, response);
}

```

i wan't to get the page from servlet after check login authentication , but not without passing parameters in link like that:`

```
$.ajax({
                    url: 'identification',
                    type: 'POST',
                    data:{pass:$hash,name:$name},
                    timeout: 1000,
                    success: function(data){
                     var target = document.getElementById('spinner');
                                    spinner = new Spinner(opts).spin(target);
                                    $('#spinner').fadeIn();

                                    if (data=='error')
                                    {
                                    $("#messages").html(" Check your username and password.");
                                    $('#name').css('border-color','#B94A48');
                                    $('#pass').css('border-color','#B94A48');
                                    $('#spinner').fadeOut();
                                    }

                                    else 

                                        {
                                        $("#messages").html("");

            $('#spinner').fadeOut();
                                    window.location ="/BookListServlet?name="+$name;
                                    }

                }
            });`

```