[ casperns2 @ 19.07.2014. 20:32 ] @
Pozdrav, da li neko ima ideju zasto mi ne radi response.sendRedirect metod . Ocitaju se podaci i dodje se do response.sendRedirect i tu nista se ne desava. Ni gdesku , nista...

Evo i koda od servleta..

Code:
package ServletModel;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import Servlet.Korisnik;
import ServletDAO.KorisnikDAO;

import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.ObjectMapper;

public class LoginServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;
    KorisnikDAO korisnikDAO =new KorisnikDAO();

    public LoginServlet() {
        super();
        // TODO Auto-generated constructor stub
    }


    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String jsonRequest = request.getParameter("jsonData");
        ObjectMapper mapper = new ObjectMapper();
        Korisnik k;
        try{
            k = mapper.readValue(jsonRequest, Korisnik.class);
            String ime = k.getIme();
            String lozinka = k.getLozinka();
            System.out.println("!!!usernamee: "+ime+"; passowrd: "+lozinka+"!!!");
            if(korisnikDAO.getKorisnikByImeAndLozinka(ime, lozinka)==null){
                System.out.println("korisnik ne registrovan");
                response.sendRedirect("Login.html");
                return;
            }else{
                System.out.println("korisnik registrovan");
                response.sendRedirect("Index.html");
                return;
            }
                    
        }catch(JsonParseException ej){
            
        }
    }
    
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
    }

}


Pretrazio sam po internetu forume i sve sam uradio kako predlazu ali ne desava se nista , na serveru se ispise "korisnik registrovan" , znaci ceo kod prosao bey greske i onda response.sendRedirect("Index.html"); ne odradi posao. Index.html se nalazi u WebContent -u . Da li je potrebno neke plugine da instaliram ili neku biblioteku da ubacim ...

evo i web.xml kako izgleda,

Code:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>Filmoteka</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
  <servlet>
    <description></description>
    <display-name>LoginServlet</display-name>
    <servlet-name>LoginServlet</servlet-name>
    <servlet-class>ServletModel.LoginServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>LoginServlet</servlet-name>
    <url-pattern>/LoginServlet</url-pattern>
  </servlet-mapping>
</web-app>


Sto je najgore pre par dana sam pisao projekte na kojima je response.sendRedirect bez problema radio i pozivao zeljene stranice i sada odjednom ne radi ???
Hvala za svaki savet ...