Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!

sathya rajavel

Greenhorn
+ Follow
since May 30, 2011
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by sathya rajavel

Hi,

I have to create dynamic menu in struts2.and the menus wants to come from database using json....
9 years ago
I have a requirement where in I have to implement a technique to validate the user before he starts accessing the application. Also, I need to check if a valid user has logged in whenever he accesses any page in the application. If the user has not logged in, then I should redirect the user to the login screen.

So I am using a Login Authentication filter to do this. I have placed the login related xhtml files in a folder /login/. Once the user is authenticated, then he is directed to application pages which are placed under /pages/... folder.

My filter mapping is given below:

<filter>
<filter-name>LoginFilter</filter-name>
<filter-class>com.validate.LoginFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>LoginFilter</filter-name>
<url-pattern>faces/pages/*</url-pattern>
</filter-mapping>

Scenario 1:
When the user access the login page directly from the browser, the login.xhtml page loads correctly. On click of login button in login.xhtml, the user is authenticated and transfered to application specific pages under /pages/welcomeuser.xhmtl. The filter is not invoked on click of login button in login.xhtml at this point in time, because the mapped url for filter is faces/pages/*. This scenario works fine.

Scenario 2:
Let's assume the user directly types the URL http://localhost:8020/pages/welcomeuser.xhtml. the expected behaviour should that the user should redirected to /login.login.xhtml page as the user is not validated yet.

In this case, the doFilter () method in LoginFilter is invoked. Inside this method, I am checking if the user object exists or not. If not exists, then I am redirecting the user to /login/login.xhtml. What happens now is, since I am doing a redirect to a page whose URL pattern matches with URL pattern of filter, it calls the doFilter() again and again and this goes into a indefinite loop.

Please let me know how to overcome this.

The do filter method is given below:

<code>
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
try {
log.info("doFilter ");
HttpServletRequest request = (HttpServletRequest) servletRequest;
CfsaosDTO cfsaosDTO = (CfsaosDTO) request.getSession().getAttribute("loggedInUser1");

log.info("doFilter1 " + cfsaosDTO);

CFSSecurityFactory.setCurrentUser(cfsaosDTO);
filterChain.doFilter(servletRequest, servletResponse);

// if(cfsaosDTO.equals(null))
// request.setAttribute("errorMsg", "Login Required");
// request.getRequestDispatcher(errorURL).forward(request, servletResponse);
// request.getRequestDispatcher("/index.jsp").forward(request, servletResponse);




} finally{

// UserUtil.removeUserId();
}
}
}

Thanks.
9 years ago
JSF
Here Arraylist contains value but the datasource returns null.please please help me


Hi I have created the report design where the both rows and columns grow dynamically .So in columns i pass the parameters and for rows to grow dynamically i have given the firld names both the params and fields i have given with the extension from DTO.
Now in action class.The fields which are to be displayed i have stored in a list and in struts.xml file for the datasource i have given this list name.Nowthye list contains value.but in pdf its showing null.




Jrxml file


Hai

I have created a file upload and i make the uploaded file to save in folder.

Now once it get uploaded i created a hyperlink by clicking on the link it should get download please send me the full code for download

Cheers,
Sathya.

10 years ago

how to download a file which is uploaded using struts 2

10 years ago


i want to create system tray
while clicking the system tray it should open a frame for login

10 years ago