Problema com integração de sistemas

Pessoal,

Estou fazendo a integração de uma aplicação em PHP com uma aplicação em Java utilizando Web Services Eclipse/Axis.

Mas estou tendo um problema com a seguinte etapa.

Preciso executar uma determinada classe:


public void doFilter(ServletRequest request, ServletResponse response,
            FilterChain chain)
            throws IOException, ServletException {
        
        String url = ((HttpServletRequest) request).getRequestURL().toString().toLowerCase();
        String file = url.substring(url.lastIndexOf("/") + 1);
        
            //check for an active session
            if(((HttpServletRequest) request).getSession(false) == null) {
                ((HttpServletResponse) response).sendRedirect("/jsp/menu.jsp");
                return;
            }
            
            
            //intercept all files matching the pattern: pres_*.ram
            if(file.startsWith("pres_")) {
                int max;
                try {
                    max = Integer.parseInt(ResourceBundle.getBundle("br.com.empresa.www.aplic.aplicacao_config").getString("stream.users.max"));
                } catch(Exception e) {
                    max = 50;
                }
                
                try {
                    String idStr = file.substring(0, file.indexOf(".")).substring(file.indexOf("_") + 1);
                    long id = Long.parseLong(idStr);
                    
                    DAO presentationDAO = DAOFactory.getDAOInstance(DAOFactory.PRESENTATION_DAO, request.getLocale());
                    Presentation p = (Presentation) presentationDAO.getObject(id);
                    
                    if(p.getPresentationType().equals(Presentation.LIVE_PRESENTATION)) {
                        if(SmilRequestFilter.currentUsers >= max) {
                            ((HttpServletResponse) response).sendRedirect("/jsp/userLimitExceeded.jsp");
                            return;
                        }
                    }
                    
                    String port;
                    try {
                        port = ResourceBundle.getBundle("br.com.empresa.www.aplic.aplicacao_config").getString("server.http.port");
                    } catch(Exception e) {
                        port = "80"; //HTTP default
                    }
                    
                    Long uid = null;
                    try {
                        User u = ((User) ((HttpServletRequest) request).getSession().getAttribute("user"));
                        uid = u.getId();
                    } catch(Exception e) { }
                    
                    String ramContent = "http://" + request.getServerName() + ":" + port +
                            ((HttpServletRequest) request).getContextPath() +
                            "/userid" + uid + "/pres_" + id + ".smil\n\n";
                    
                    HttpServletResponse httpResponse = (HttpServletResponse) response;
                    httpResponse.setStatus(HttpServletResponse.SC_OK);
                    httpResponse.setDateHeader("Last-Modified", System.currentTimeMillis());
                    httpResponse.setDateHeader("Date", System.currentTimeMillis());
                    httpResponse.setContentType("audio/x-pn-realaudio");
                    httpResponse.setContentLength(ramContent.length());
                    
                    httpResponse.getOutputStream().write(ramContent.getBytes());
                    
                    httpResponse.getOutputStream().close();
                } catch(Exception e) {
                    e.printStackTrace();
                }
                
                return;
            }
}

Mas como estou logando nessa aplicação não consigo pegar alguns dados que estão na sessão.

Uma outra saída foi seria fazer um método no meu agente web services, fiz o seguinte método:


public java.lang.String[] openPresentation(java.lang.String[] openPresentationRequest) throws java.rmi.RemoteException {

    	System.out.println("oi");
    	
    	String[] result = new String[1];
    	
    	//result[0] = "oi";
    	
    	String url = openPresentationRequest[0];
    	String cliente = openPresentationRequest[1];
    	String usuario = openPresentationRequest[2]; 
    	
    	System.out.println(url);
    	System.out.println(cliente);
    	System.out.println(usuario);
    	
    	String file = url.substring(url.lastIndexOf("/") + 1);
        if(file.endsWith(".ram")) {
            //check for an active session
            //if(((HttpServletRequest) request).getSession(false) == null) {
            //    ((HttpServletResponse) response).sendRedirect("/jsp/menu.jsp");
            //    return;
            //}
            
            
            //intercept all files matching the pattern: pres_*.ram
            if(file.startsWith("pres_")) {
                int max;
                try {
                    max = Integer.parseInt(ResourceBundle.getBundle("br.com.empresa.www.aplic.aplicacao_config").getString("stream.users.max"));
                } catch(Exception e) {
                    max = 50;
                }
                
                try {
                    String idStr = file.substring(0, file.indexOf(".")).substring(file.indexOf("_") + 1);
                    long id = Long.parseLong(idStr);
                    
                    DAO presentationDAO = DAOFactory.getDAOInstance(DAOFactory.PRESENTATION_DAO);
                    Presentation p = (Presentation) presentationDAO.getObject(id);
                    
                    if(p.getPresentationType().equals(Presentation.LIVE_PRESENTATION)) {
                        //if(SmilRequestFilter.currentUsers >= max) {
                       //     ((HttpServletResponse) response).sendRedirect("/jsp/userLimitExceeded.jsp");
                       //     return;
                       // }
                    }
                    
                    String port;
                    try {
                        port = ResourceBundle.getBundle("br.com.empresa.www.aplic.aplicacao_config").getString("server.http.port");
                    } catch(Exception e) {
                        port = "80"; //HTTP default
                    }
                    
                    
                    
                    ClientDAO cDAO = (ClientDAO) DAOFactory
            		.getDAOInstance(DAOFactory.CLIENT_DAO);
            		ClientFilter clientFilter = new ClientFilter();
            		try {
            			clientFilter.setLink(cliente);
            		} catch (Exception e) {
            		}
            		List clientList = null;
            		try {
            			clientList = cDAO.searchObjects(clientFilter);
            		} catch (IllegalArgumentException e) {
            			// TODO Auto-generated catch block
            			e.printStackTrace();
            		} catch (SQLException e) {
            			// TODO Auto-generated catch block
            			e.printStackTrace();
            		}
            		long clientId = 0;
            		for (int i = 0; i < clientList.size(); i++) {
            			Client c = (Client) clientList.get(i);
            			clientId = c.getId();
            		}

            		UserDAO uDAO = (UserDAO) DAOFactory.getDAOInstance(DAOFactory.USER_DAO);
            		UserFilter userFilter = new UserFilter();
            		userFilter.setUsername(usuario);
            		userFilter.setClientId(clientId);
            		List userList = null;
            		try {
            			userList = uDAO.searchObjects(userFilter);
            			if (userList.size() > 0) {
            				
            			} else {
            				
            			}
            		} catch (IllegalArgumentException e) {
            			// TODO Auto-generated catch block
            			e.printStackTrace();
            		} catch (SQLException e) {
            			// TODO Auto-generated catch block
            			e.printStackTrace();
            		}
            		
            		long userId = 0;
            		for (int i = 0; i < userList.size(); i++) {
            			User u = (User) userList.get(i);
            			userId = u.getId();
            		}
                    
                    
                    
                    String ramContent = "http://192.168.20.60:" + port + "/axis" +
                            "/userid" + userId + "/pres_" + id + ".smil\n\n";
                    
                    System.out.println(ramContent);
                    
                    
                    
                                     
                    
                    
                    HttpServletResponse httpResponse = null;
                    
                    httpResponse.setStatus(HttpServletResponse.SC_OK);
                    httpResponse.setDateHeader("Last-Modified", System.currentTimeMillis());
                    httpResponse.setDateHeader("Date", System.currentTimeMillis());
                    httpResponse.setContentType("audio/x-pn-realaudio");
                    httpResponse.setContentLength(ramContent.length());
                    
                    httpResponse.getOutputStream().write(ramContent.getBytes());
                    
                    httpResponse.getOutputStream().close();
                } catch(Exception e) {
                    e.printStackTrace();
                }
                
                return result;
                
                
            }
        }
		return result;
    	
    }

O problema dessa classe é executar essa etapa:

HttpServletResponse httpResponse = null;

httpResponse.setStatus(HttpServletResponse.SC_OK);
httpResponse.setDateHeader(“Last-Modified”, System.currentTimeMillis());
httpResponse.setDateHeader(“Date”, System.currentTimeMillis());
httpResponse.setContentType(“audio/x-pn-realaudio”);
httpResponse.setContentLength(ramContent.length());

Pois fica null.

Alguém tem alguma idéia, vamos discutir, pois preciso fazer essa bagaça funcionar.

Obrigado.

Olá,

Será que depois do…

HttpServletResponse httpResponse = null;

você não deveria fazer:

HttpServletResponse httpResponse = new HttpServletResponse();

??

Até logo!

Dá um erro no eclipse dizendo que não pode instanciar o tipo HttpServletResponse.