JSF :: Lifecycle Is Not Getting Called After Servlet Filter Forward Or Redirect

Jul 11, 2014

I have a scenario here where the JSF lifecycle is not getting invoked. I have a filter, whose responsibility is to filter only authorized requests. The code of the filter is given below

public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
HttpServletRequest httpRequest = (HttpServletRequest)request;
HttpServletResponse httpResponse = (HttpServletResponse)response;

[Code] ....

Now in the else block I am filtering the unauthorized requests, and sending them back to the Login.xhtml page of the application.

The problem I am encountering here is that, the images and styles associated with the page are not getting loaded, what i am thinking is that when i am using redirect or forward, the FacesServlet is not getting called, and it is directly going to Login page i.e. no Lifecyle is being called.

Am I right on this?, if so how to Filter the requests and at same time not lose the style?

View Replies


ADVERTISEMENT

JSF :: Lifecycle Is Not Getting Called After Servlet Filter Forward Or Redirect

Jul 11, 2014

I have a scenario here where the JSF lifecycle is not getting invoked. I have a filter, whose responsibility is to filter only authorized requests.the code of the filter is given below

public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
HttpServletRequest httpRequest = (HttpServletRequest)request;
HttpServletResponse httpResponse = (HttpServletResponse)response;

[code]....

now in the else block i am filtering the unauthorized requests, and sending them back to the Login.xhtml page of the application.The problem i am encountering here is that, the images and styles associated with the page are not getting loaded, what i am thinking is that when i am using redirect or forward, the FacesServlet is not getting called, and it is directly going to Login page i.e. no Lifecyle is being called.how to Filter the requests and at same time not lose the styles?

View Replies View Related

Servlets :: Filter Not Being Called

Nov 10, 2014

I have Filter that is randomly being called and randomly not being called without any logical reason...The mapping is very simple:

<filter>
<filter-name>MyFilter</filter-name>
<filter-class>com.me.MyFilter</filter-class>
<init-param>
<param-name>ignorePaths</param-name>
<param-value>res/</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>MyFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

[code]....

So, init is called, so it works... but most of the time the doFilter method is not being called at all... what am I doing wrong?

View Replies View Related

JSF :: Get Data From Managed Bean Method After Servlet Filter

Feb 15, 2015

I have a situation to load data while JSF page loads. Also have a filter which populates user information from http request.

I was expecting the filter first to populate the user information and in the managed bean get method to verify the user information and get the data (from database). But in this case i see the managed bean get method is invoked before filter populates user information and i get null pointer exception because the user information is null.

I had to work around to get the user information from FacesContext in the managed bean get method because the user information wasn't available. Is there a way to make sure the filter is invoked first?

View Replies View Related

Write A Class Called Coin Which Will Be Used By A Program Called CountFlips

May 1, 2014

i am trying to write a coin program:Write a class called Coin which will be used by a program called CountFlips.

1. The class, is an object created from this program. It is composed of data values and methods. It should contain a main method and should output the number of flips done (an integer that will be read from the user), the number of heads and tails that occur.

2. The CountFlip class will flip a coin multiple times and counts the number of ‘heads’ and ‘tails’ that result. This class should have a method called flip() of type void; a method called isHead() of type Boolean and a toString() method that will return the current face of the coin as a string.

So i created 2 classes, one called Coin.java & the other CountFlips.java,

PHP Code: package test;
public class Coin {
private final int heads = 0;
private final int tails = 1;
private int facetype;
private int flips;

[code]....

View Replies View Related

Servlets :: How To Forward Request To Another Web Application

Jun 14, 2014

I have to forward my request to another webApplication using post request parameters. In this case Webaplication-1 need send request using post request params to Webapplication-2 & once Webaaplication-2 receives request it has to process & display output.

For this have tried below 2 options which Servlet API provides.

1. RequestDispatcher : this will used to forward request to another resource within the application.

2. sendRedirect() : this method support doGet() of Servlet.

3. Using HttpClient, which is provided by Apache able to do but it will not displaying Output,It sending back response to Webapplication-1 .

Is there any option which will handover request from one webapplication to another webapplication.

View Replies View Related

Servlets :: Context Path After Forward

Mar 23, 2015

I have normal adress which works, like

localhost/contextPath/foo

In URL rewrite filter I forward that call like

((HttpServletRequest) req).getRequestDispatcher(".....foo1.jsp").forward(req, res);

And it gets there. On that page (foo1.jsp) I have link to original href

<a href="localhost/contextPath/foo">click.</a>

When I click that, in url rewrite filter I get:

String url = ((HttpServletRequest)req).getRequestURL().toString();// http://contextPath/foo/contextPath/foo
String uri = ((HttpServletRequest)req).getRequestURI().toString();// /contextPath/foo/contextPath/foo

which is bad address. How to handle that and why it happens ?

View Replies View Related

How To Complete For Loop For Forward Method

Mar 3, 2015

I can't figure out how to complete the for loop for the forward method that needs to calculate each pixel on the path setting it to white, starting at location (x,y) and ending at r.

public class Turtle
{
private static BufferedImage img;
private static int black = 0;
private static int blue = 255; // 2^8-1
private static int green = 65280; //(2^8-1)*2^8
private static int red = 16711680; //(2^8-1)*2^16
private static int white = 16777215; // 2^24-1
private double x,y,theta; // what does a Turtle know?
static // a static initializer list

[code]....

View Replies View Related

Unable To Differentiate Legal And Illegal Forward Reference

Mar 16, 2014

I understand that the following is an example of valid reference in java. I also understand that at class creation, first i and j are initialized to 0. j is then re-initialized to 5, as a result of which i's value is 0 and j's is 5 inside main.

class J
{
static int test() {
return j;
}
static int i = test();
 
[Code] ....

But why is the same not true for the following ? Why is it that i and j are not initialized to the default value of 0 in this case and gives an illegal forward reference?

class test
{
static int i = j;
static int j=5;
  public static void main(String[] args) {
System.out.println(i);
System.out.println(j);
}
}

Why is it legal forward reference when using a method, and illegal when pretty much the same thing is done using a variable ?

View Replies View Related

List Iterator Execution - Traversing In Forward Direction

Nov 5, 2014

List<Integer> list = new ArrayList<Integer>();
for (int i = 0; i < 5; i++) {
list.add(i * 3);
}
ListIterator<Integer> listItr = list.listIterator();
System.out.println("Traversing in a forward direction");

[Code] ....

Output:--

Traversing in a forward direction
0 3 6 9 12
Traversing in a backward direction
12 9 6 3 0 425

Why 425 is not showing when we are traversing in a forward direction.

View Replies View Related

Java Servlet :: Showing Error While Compiling Servlet

Jan 23, 2013

I am a beginner want to compile servlet with following path

javac -classpath Program FilesApache Software FoundationTomcat 5.5commonlibservlet-api.jar;classes:.-d classes srccomexamplewebBeerSelect.java

Problem arises as follows:

javac: invalid flag: FilesApache
Usage: javac <options> <source files>
use -help for a list of possible options

View Replies View Related

Servlets :: Redirect After Login

Jan 30, 2014

I have a secured Struts application in WebSphere that uses FORM j_security_check for authentication.There is also a Post Logon "filter" defined which runs some code after a login is processed.The extract from web.xml showing the login configuration and filter is as follows:

<login-config>
<auth-method>FORM</auth-method>
<realm-name>MyRealm</realm-name>
<form-login-config>
<form-login-page>/login.html</form-login-page>
<form-error-page>/error.html</form-error-page>

[code]....

If a user isn't logged into the application and they try to access one of the secured servlets, for example quotes.do, they are directed to the login page to enter their information.If they login successfully, they are then directed to quotes.do, rather than the default "welcome" page. Is there a setting in the web.xml or the post logon filter where I can force j_security_check to ALWAYS go to the default welcome page after a successful login?

View Replies View Related

Redirect Error In JavaScript

May 1, 2014

I am trying to run a sign up page. The page is working properly and takes me to the login page when completed as it should. But when a field is left blank it is supposed to show an error message and keep them on the signup page, and it is not doing that. Sign Up Action:

<%
String field = "";
String message = "";
if ((request.getParameter("lastname") != null) &&
(request.getParameter("firstname") != null) &&
(request.getParameter("sadress") != null) &&
(request.getParameter("city") != null) &&
(request.getParameter("state") != null) &&
(request.getParameter("zipcode") != null) &&

[code]....

View Replies View Related

JSP :: Losing Session Values During Redirect?

Mar 30, 2014

I am trying Single signon to a different application from my application. i use redirect to open the new URL in a separate window. MY single signon works well. But i am losing the session values in my application.

Because of this when i close the new window and click on any link in my application, i am getting error sicne all application objects inside session are reset to null. how to retain the session values after Redirect.

View Replies View Related

JSF :: SSO Class - How To Redirect To Login Page

Jul 20, 2014

I have write a SSO class for Single Sign on But i am getting one issue i am using JSF2 for my web application...here is my SSO class :

public class ApplicationSSO implements SSO {
public String authenticateUser(RequestContext request) {
UmUsersList user = (UmUsersList) request.getSessionContext().getAttribute("USER");
return user.getUmulEmailId();
}

[Code] .....

As you can see i have write below line

JSFUtils.redirectPage("../login/Login.xhtml");

It mean if User null it will redirect to Login page but it is not working. How to solve the issue i am end up with

An error has occurred.

For detailed error information, please see the HTML source code, and contact the forum Administrator.

Error while executing SSO actions: java.lang.NullPointerException

View Replies View Related

Keep PrintStream Redirect Across Multiple Scenes

Feb 26, 2015

I have a JavaFX application with multiple scenes. In the application one scene plays the "master" role and the others are loaded according to actions . The issue i have is that i need to redirect all the PrintStream activity to a specific TextArea on the "master" scene, and by "all" i am meaning every PrintStream activity on every scene should be redirected to this specific TextArea . The code i am using on the "master" is :

Node node =primaryStage.getScene().lookup("#ShowInfo");
TextArea ta =(TextArea)node;
FXConsole console = FXConsole.getInstance(ta);
PrintStream ps = new PrintStream(console, true);
System.setOut(ps);
System.setErr(ps);
System.out.println("Test");

I am using the Singleton pattern for the rest of the scenes :

FXConsole console = FXConsole.getInstance(null);
PrintStream ps = new PrintStream(console, true);
System.setOut(ps);
System.setErr(ps);
System.out.print("Hello There");
ps.close();

The issue is that i don't like this implementation ....

View Replies View Related

Redirect To Local HTML File

Aug 1, 2014

I edited some lines from "[URL] ...." and saved it as html file; now if a friend want to do a search in Wikipedia for cats, the edited page should show up instead of original page.Is there a way to do this using java script.

View Replies View Related

Redirect SetInputStream And SetOutputStream Of JSch

Feb 18, 2014

I use the jsch libraries to create a SHH connection to a remote linux machine. In the next code, given from a tutorial of the JSCH creator, you can see it is implemented shell communication, it is a direct communication from a cmd window. You enter a command from the cmd window and you get aback the results in the cmd window.

Java Code:

String user = "username";
String host = "hostname";
ession session=jsch.getSession(user, host, 22);
String passwd = JOptionPane.showInputDialog("Enter password");
session.setPassword(passwd);
Channel channel=session.openChannel("shell");
session.connect();
channel.setInputStream(System.in);
channel.setOutputStream(System.out); mh_sh_highlight_all('java');

How i can redirect the next two lines to jTextField1 and jTextField2. To give an example i want to sen the command from the jTextField1 and to get the results from the jTextField2.

Java Code:

channel.setInputStream(System.in);
channel.setOutputStream(System.out); mh_sh_highlight_all('java');

View Replies View Related

Servlets :: IE And Firefox Use GET After HTTPS Redirect With TOMCAT 7

Jun 3, 2014

I have a simple application ( only 2 JSPs files and one servlet the main components the whole webapp directory is attached ), I am using security constraint to redirect the user to HTTPS instead of HTTP when he submit from first page to the second page.

The problem is when the user submit the first page I get the error HTTP Status 405 - HTTP method GET is not supported by this URL although I m using only POST.

I have traced the firefox browser using httpfox and the result was the first HTTP request was done using POST correctly but after redirect the browser send GET.

This problem appears with FireFOx and IE but doesnot appear with google chrome.

index.jsp

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="myTags" tagdir="/WEB-INF/tags" %>
<html>
<head>
<title>Welcome Page</title>
<link href="css/style.css" type = "text/css" rel="stylesheet" />

[Code] ......

View Replies View Related

Servlets :: How To Redirect A Console Output To Textarea

May 8, 2014

i am doing a program that allow user to run and execute java language in this commandline.jsp, a servlet execute.java , jsp called get consoleout put.jsp to direct it to commandline.jsp...however there a compilation errors cos i could only get a line of string, and when i run loop in commandline.jsp it will not have the output. i could only run helloworld in it.therefore i need code that i can run multiple line in it. i suspect its the print stream error in execute.java

<!DOCTYPE html>
<html>
<head>
<title>java interpreter</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script src="jquery-linedtextarea.js"></script>
<link href="jquery-linedtextarea.css" type="text/css" rel="stylesheet" />

[code]....

View Replies View Related

JavaFX 2.0 :: Keep PrintStream Redirect Across Multiple Scenes

Feb 26, 2015

I have a JavaFX application with multiple scenes. In this applications one scene plays the role of "master" role and the others are loaded according to actions on the "master" scene(buttons,menu items)

The issue is that i need to redirect all the PrintStream activity to a specific TextArea on the "master" scene...

So everything that normally goes to the console to get redirected to that specific TextArea and this should be global,on every scene that is outputting something it should displayed on the specific TextArea on the "master" scene
 
The code i am using right now on the "master" scene is :
 
            Node node =primaryStage.getScene().lookup("#ShowInfo");
            TextArea ta =(TextArea)node;
            FXConsole console = FXConsole.getInstance(ta);
            PrintStream ps = new PrintStream(console, true);
            System.setOut(ps);
            System.setErr(ps);
            System.out.println("Test");
 
For the rest of the scenes i am using the Singleton Pattern to keep the pointing to the Specific TextArea
 
       FXConsole console = FXConsole.getInstance(null);
        PrintStream ps = new PrintStream(console, true);
        System.setOut(ps);
        System.setErr(ps);
        System.out.print("Hello There");
        ps.close();
 
The issue is that i don't like this implementation so ...is there a better solution

View Replies View Related

File Filter In JTree

Apr 4, 2014

My goal is to display file that have extension *.java,I was wrote this swing in netbeans,

Java Code:
private static class FileSystemModel implements TreeModel {
private File root;
private Vector listeners = new Vector();
public FileSystemModel(File rootDirectory) {
root = rootDirectory;

[code]....

View Replies View Related

JSF :: Getting ClassNotFoundException When Trying To Implement Web Filter In App

Feb 6, 2014

I have a JSF app and for some reasons i need to refresh the page on browser back button.I tried implementing the solution given in Force JSF to refresh page / view / form when back button is pressed ,the only difference is that my app runs with servlet version 2.5 so i did the mapping in web.xml as below

<?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" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
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">
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<context-param>
<param-name>javax.faces.CONFIG_FILES</param-name>
<param-value>/WEB-INF/faces-config.xml</param-value>
</context-param>

[code]....

View Replies View Related

JSF :: IllegalState Exception From Backing Bean Redirect To External Site

Dec 11, 2014

I am using a command button to post a form to backing bean method. At the end of that method I am attempting to redirect to an external site after setting various options in the response. I get an IllegalState Exception because of the redirect.

at com.ibm.ws.webcontainer.webapp.WebAppDispatcherContext.sendRedirectWithStatusCode
(WebAppDispatcherContext.java:571)
at com.ibm.ws.webcontainer.webapp.WebAppDispatcherContext.sendRedirect
(WebAppDispatcherContext.java:528)
at com.ibm.ws.webcontainer.srt.SRTServletResponse.sendRedirect(SRTServletResponse.java:1234)
at com.sun.faces.context.ExternalContextImpl.redirect(ExternalContextImpl.java:426)
at com.sun.faces.application.NavigationHandlerImpl.handleNavigation(NavigationHandlerImpl.java:181)

here is the problem code from the backing bean method:

if ( redirectPage != null ) {
logger.debug("attempting redirect: " +

View Replies View Related

Swing/AWT/SWT :: Implement The Median Filter?

Jun 10, 2014

I have to implement the median filter. I found an example on the internet but it does not run, I do not see the image

public void median_RGB(Immagine img) {
int maskSize = 3;
int width = img.getW();

[Code]....

View Replies View Related

Non Local Means Filter Implementation In Java?

Feb 23, 2014

How to implement non local means filter in java?

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved