Problem with LoginInterceptor
Hi, recently I was told using Interceptors was better than using a BaseAction object performing the login process. I agree. Still I have some trouble: This is what happens: I have a JSP that creates a button liked with another action: AgencyDetails.jsp - ... s:url id=url value=/rating/Rate s:param name=staffResourceIds:property value=staffResource.id //s:param /s:url s:a href=%{url}buttonPlace Rating!/button/s:abr ... - This is the struts.xml configuration for that Action: rating.xml - package name=rating namespace=/rating extends=default default-interceptor-ref name=defaultLoginStack / action name=Rate class=de.mathiasewald.projektseminar.action.rating.Rate result /rating/Rate.jsp /result /action /package - This is the inteceptor stack in struts.xml - interceptors interceptor name=login class=de.mathiasewald.projektseminar.interceptor.LoginInterceptor /interceptor interceptor-stack name=defaultLoginStack interceptor-ref name=login / /interceptor-stack /interceptors - and finally the LoginInterceptor.java - public class LoginInterceptor extends AbstractInterceptor implements StrutsStatics { /** * */ private static final long serialVersionUID = -6647897949084333127L; private LoginManager loginManager = new LoginManager(); private static final Log log = LogFactory.getLog(LoginInterceptor.class); private static final String USER_HANDLE = QUADRAN_USER_SESSSION_HANDLE; private static final String LOGIN_ATTEMPT = QUADRAN_LOGIN_ATTEMPT; private static final String USERNAME = QUADRAN_USERNAME; private static final String PASSWORD = QUADRAN_PASSWORD; public void init () { log.info (Intializing LoginInterceptor); } public void destroy () {} public String intercept (ActionInvocation invocation) throws Exception { // Get the action context from the invocation so we can access the // HttpServletRequest and HttpSession objects. final ActionContext context = invocation.getInvocationContext (); HttpServletRequest request = (HttpServletRequest) context.get(HTTP_REQUEST); HttpSession session = request.getSession (true); // Is there a user object stored in the user's HttpSession? Object user = session.getAttribute (USER_HANDLE); if (user == null) { // The user has not logged in yet. // Is the user attempting to log in right now? String loginAttempt = request.getParameter (LOGIN_ATTEMPT); if (loginAttempt != null loginAttempt.trim().length() 0) { // The user is attempting to log in. log.info(User tries to log in - processing attempt...); // Process the user's login attempt. if (processLoginAttempt (request, session) ) { // The login succeeded send them the login-success page. log.info(User + loginAttempt + logged in successfully.); return invocation.invoke (); } else { // The login failed. Set an error if we can on the action. log.info(Error authenticating user + loginAttempt); Object action = invocation.getAction (); if (action instanceof com.opensymphony.xwork2.ValidationAware) { ((com.opensymphony.xwork2.ValidationAware) action).addActionError (Username or password incorrect.); } } } // Either the login attempt failed or the user hasn't tried to login yet, // and we need to send the login form. return login; } else { return invocation.invoke (); } } /** * Attempt to process the user's login attempt delegating the work to the * SecurityManager. */ public boolean processLoginAttempt (HttpServletRequest
Re: Problem with LoginInterceptor
Thx for the reply! I checked the Login Intercepter Tutorial once again and recognized I forgot some Interceptors as you told. This is what they suggest to define: You need to include one of the framework interceptor stacks (e.g defaultStack) in your defaultLoginStack stack. As you have configured it, your interceptor is the only one that is being executed, so none of the framework magic gets applied. - interceptors interceptor name=login class=de.mathiasewald.projektseminar.interceptor.LoginInterceptor /interceptor interceptor-stack name=defaultLoginStack interceptor-ref name=servlet-config / interceptor-ref name=params / interceptor-ref name=login / interceptor-ref name=prepare / interceptor-ref name=chain / interceptor-ref name=model-driven / interceptor-ref name=fileUpload / interceptor-ref name=static-params / interceptor-ref name=params / interceptor-ref name=conversionError / interceptor-ref name=validation / interceptor-ref name=workflow / /interceptor-stack interceptor-stack name=defaultInsecureStack interceptor-ref name=servlet-config / interceptor-ref name=params / interceptor-ref name=prepare / interceptor-ref name=chain / interceptor-ref name=model-driven / interceptor-ref name=fileUpload / interceptor-ref name=static-params / interceptor-ref name=params / interceptor-ref name=conversionError / interceptor-ref name=validation / interceptor-ref name=workflow / /interceptor-stack /interceptors - This brings up the following Exception as Tomcat starts: - Jul 20, 2009 12:38:50 PM org.apache.tomcat.util.digester.SetPropertiesRule begin WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:projektseminar' did not find a matching property. Jul 20, 2009 12:38:50 PM org.apache.catalina.core.AprLifecycleListener init INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/lib/jvm/java-6-sun-1.6.0.14/jre/lib/amd64/server:/usr/lib/jvm/java-6-sun-1.6.0.14/jre/lib/amd64:/usr/lib/jvm/java-6-sun-1.6.0.14/jre/../lib/amd64:/usr/lib64/xulrunner-addons:/usr/java/packages/lib/amd64:/lib:/usr/lib Jul 20, 2009 12:38:50 PM org.apache.coyote.http11.Http11Protocol init INFO: Initializing Coyote HTTP/1.1 on http-8080 Jul 20, 2009 12:38:50 PM org.apache.catalina.startup.Catalina load INFO: Initialization processed in 692 ms Jul 20, 2009 12:38:50 PM org.apache.catalina.core.StandardService start INFO: Starting service Catalina Jul 20, 2009 12:38:50 PM org.apache.catalina.core.StandardEngine start INFO: Starting Servlet Engine: Apache Tomcat/6.0.20 12:38:51,865 INFO XmlConfigurationProvider:31 - Parsing configuration file [struts-default.xml] 12:38:51,991 INFO XmlConfigurationProvider:31 - Parsing configuration file [struts-plugin.xml] 12:38:52,075 INFO XmlConfigurationProvider:31 - Parsing configuration file [struts.xml] Jul 20, 2009 12:38:52 PM org.apache.catalina.core.StandardContext filterStart SEVERE: Exception starting filter struts2 Unable to load configuration. - interceptor-ref - file:/home/mathias/.workspace_j2ee/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/projektseminar/WEB-INF/classes/struts.xml:23:46 at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:58) at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:360) at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:403) at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:69) at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:48) at
Re: Problem with LoginInterceptor
Hi, yes I am using the latest version of struts2. Most likely the tutorials I used refer to other versions. I set the struts.xml as follows: --- interceptors interceptor name=login class=de.mathiasewald.projektseminar.interceptor.LoginInterceptor / interceptor-stack name=defaultLoginStack interceptor-ref name=servletConfig / interceptor-ref name=params / interceptor-ref name=login / interceptor-ref name=prepare / interceptor-ref name=chain / interceptor-ref name=modelDriven / interceptor-ref name=fileUpload / interceptor-ref name=staticParams / interceptor-ref name=params / interceptor-ref name=conversionError / interceptor-ref name=validation / interceptor-ref name=workflow / /interceptor-stack interceptor-stack name=defaultInsecureStack interceptor-ref name=servletConfig / interceptor-ref name=params / interceptor-ref name=prepare / interceptor-ref name=chain / interceptor-ref name=modelDriven / interceptor-ref name=fileUpload / interceptor-ref name=staticParams / interceptor-ref name=params / interceptor-ref name=conversionError / interceptor-ref name=validation / interceptor-ref name=workflow / /interceptor-stack /interceptors --- The errors about unfindable interceptors disappeard. But still, the parameter is not preserved. Any suggestions? cu mathias -- View this message in context: http://www.nabble.com/Problem-with-LoginInterceptor-tp24565562p24570331.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Problem with LoginInterceptor
Hi, so what do you suggest? Isn't there any way to do that? cu mathias mailtolouis2020-struts wrote: I don't think it will preserve your parameter by default, I might be wrong, if it do, then that is another magic in S2 I didn't know that. For what I understand is there are 2 request from the user, 1) http://localhost:8080/projektseminar/rating/Rate?staffResourceId=1 2) login submit I don't think you store a staffResourceId as a hidden param in the login page, if its not there you won't expect to come into your url. Regards Louis From: mathias-ewald nitehoax...@gmx.net To: user@struts.apache.org Sent: Monday, July 20, 2009 2:53:39 PM Subject: Re: Problem with LoginInterceptor Hi, yes I am using the latest version of struts2. Most likely the tutorials I used refer to other versions. I set the struts.xml as follows: --- interceptors interceptor name=login class=de.mathiasewald.projektseminar.interceptor.LoginInterceptor / interceptor-stack name=defaultLoginStack interceptor-ref name=servletConfig / interceptor-ref name=params / interceptor-ref name=login / interceptor-ref name=prepare / interceptor-ref name=chain / interceptor-ref name=modelDriven / interceptor-ref name=fileUpload / interceptor-ref name=staticParams / interceptor-ref name=params / interceptor-ref name=conversionError / interceptor-ref name=validation / interceptor-ref name=workflow / /interceptor-stack interceptor-stack name=defaultInsecureStack interceptor-ref name=servletConfig / interceptor-ref name=params / interceptor-ref name=prepare / interceptor-ref name=chain / interceptor-ref name=modelDriven / interceptor-ref name=fileUpload / interceptor-ref name=staticParams / interceptor-ref name=params / interceptor-ref name=conversionError / interceptor-ref name=validation / interceptor-ref name=workflow / /interceptor-stack /interceptors --- The errors about unfindable interceptors disappeard. But still, the parameter is not preserved. Any suggestions? cu mathias -- View this message in context: http://www.nabble.com/Problem-with-LoginInterceptor-tp24565562p24570331.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org -- View this message in context: http://www.nabble.com/Problem-with-LoginInterceptor-tp24565562p24570714.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Login mechanism - preserve Action parameters
Hi, a few days ago I implemented a login mechanism into my web application. Therefore I use an abstract BaseAction, that asks the implementing class wheter it want to be password protected or not. If it does and there's no object named user available the Login.jsp is shown. When the Login form returns the user object is placed into session scope. The Problem is, that after the Login.jsp has returned to the BaseAction all parameters that were passed to the implementing Action are lost. What can I do? Here' my code: BaseAction.java --- public abstract class BaseAction { public static final Integer ALLOWED = 0; public static final Integer DENIED = 1; public static final Integer DENIED_GROUP = 2; private String logout = false; private String username; private String password; protected Log log; public BaseAction() {} public String execute() { if(log == null) { log = LogFactory.getLog(getClass()); } MapString, Object session = ActionContext.getContext().getSession(); /* * if the user wants to logout, delete the object * from session scope. */ if(true.equals(logout)) { Object userObj = session.get(user); if(userObj != null) { session.put(user, null); log.info(User + ((UserAccount)userObj).getName() + logged out.); } } /* * in case the username and password values are set, perform * the login process. */ if (username != null password != null) { Session s = HibernateUtil.getSessionFactory().openSession(); Transaction tx = s.beginTransaction(); UserAccount user = (UserAccount)s.createCriteria(UserAccount.class) .add(Restrictions.eq(name, username)) .uniqueResult(); tx.commit(); s.close(); if(user == null) { log.info(Error authenticating user + username); return loginError; } String dbHash = user.getPasswordhash().toLowerCase(); String formHash = MD5Util.md5(password).toLowerCase(); if(dbHash.equals(formHash)) { session.put(user, user); log.info(User + user.getName() + logged in.); } else { log.info(Password mismatch for user + username); return loginError; } } /* * If we get this far, userObject is either successfully logged * in or null, so get the UserAccount object or set it null. */ Object userObject = session.get(user); UserAccount user = null; if(userObject != null userObject instanceof UserAccount) { user = (UserAccount)userObject; } /* * Now ask the real action if access is allowed. */ int retVal = isAllowed(user); if(retVal == ALLOWED) { return executeAction(); } else if(retVal == DENIED_GROUP) { return permissionError; } else { return login; } } public abstract String executeAction(); public abstract Integer isAllowed(UserAccount user); // getter and setter methods } --- Login.jsp --- html head jsp:include page=/common/Head.jsp/ /head body div id=container jsp:include page=/common/Header.jsp/ div id=navi Main gt; Login /div div id=body brbrbrbrbr div style=width: 40%; margin: 0 auto;
Re: Login mechanism - preserve Action parameters
Hi, newton.dave wrote: Have you considered using an interceptor for determining whether or not the user is logged in? Actions requiring login can be marked with an interface, annotation, etc. IMO this is a substantially cleaner architecture. Okay - I didn't really care about interceptors yet. Maybe its time to do that now. newton.dave wrote: I'd also *strongly* discourage tying your actions to Hibernate like this; it makes testing more difficult than necessary and introduces an unnecessary level of coupling. What do you suggest? Abstracting Hibernate from the Actions placing a data access object in between? This is a university project I have to finish untill 22nd July - I am definitly not going to do any testing ;) newton.dave wrote: All that said, I'm not really sure which parameters aren't being preserved--are you doing a redirect? One Action, for example, receives a parameter with the URL. The BaseAction the shows the Login and returns to the same Action. After that the parameter is gone. cu mathias -- View this message in context: http://www.nabble.com/Login-mechanism---preserve-Action-parameters-tp24559907p24560162.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Exception though the result looks as expected
Hi, this is the JSP script that causes the Exception: - %@ page language=java contentType=text/html; charset=UTF-8 pageEncoding=UTF-8% !DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN http://www.w3.org/TR/html4/loose.dtd; %@ taglib prefix=s uri=/struts-tags % %@ page import=com.opensymphony.xwork2.ActionContext % div class=resultElement div style= width: 40%; float: right s:set var=average value=#stat.average / % float average = (Float)ActionContext.getContext().getValueStack().findValue(#average); % % if(average 0.25f) { % button class=rating-icon-empty/button % } else if(average = 0.25f average 0.75f) { % button class=rating-icon-half/button % } else { % button class=rating-icon-full/button % } % % if(average 1.25f) { % button class=rating-icon-empty/button % } else if(average = 1.25f average 1.75f) { % button class=rating-icon-half/button % } else { % button class=rating-icon-full/button % } % % if(average 2.25f) { % button class=rating-icon-empty/button % } else if(average = 2.25f average 2.75f) { % button class=rating-icon-half/button % } else { % button class=rating-icon-full/button % } % % if(average 3.25f) { % button class=rating-icon-empty/button % } else if(average = 3.25f average 3.75f) { % button class=rating-icon-half/button % } else { % button class=rating-icon-full/button % } % % if(average 4.25f) { % button class=rating-icon-empty/button % } else if(average = 4.25f average 4.75f) { % button class=rating-icon-half/button % } else { % button class=rating-icon-full/button % } % /div h3 s:property value=#criterion.name/ /h3 table tr tdRange:/td tdnbsp;nbsp;nbsp;/td tds:property value=#criterion.min / to s:property value=#criterion.max //td /tr tr tdAverage:/td tdnbsp;nbsp;nbsp;/td td${average}/td /tr /table /div - and this is the exception: - ul 18, 2009 8:03:03 PM org.apache.catalina.core.ApplicationDispatcher invoke SEVERE: Servlet.service() for servlet jsp threw exception java.lang.NullPointerException at org.apache.jsp.details.StaffCriterionStat_jsp._jspService(StaffCriterionStat_jsp.java:76) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646) at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:551) at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:488) at org.apache.struts2.components.Include.include(Include.java:254) at org.apache.struts2.components.Include.end(Include.java:166) at org.apache.struts2.views.jsp.ComponentTagSupport.doEndTag(ComponentTagSupport.java:42) at org.apache.jsp.details.FreelancerDetails_jsp._jspx_meth_s_005finclude_005f0(FreelancerDetails_jsp.java:535) at org.apache.jsp.details.FreelancerDetails_jsp._jspx_meth_s_005fiterator_005f0(FreelancerDetails_jsp.java:462) at org.apache.jsp.details.FreelancerDetails_jsp._jspx_meth_s_005fsort_005f0(FreelancerDetails_jsp.java:416) at org.apache.jsp.details.FreelancerDetails_jsp._jspService(FreelancerDetails_jsp.java:176) at
Re: in JSP: rounding values
I don't think so - I want the exact value to be shown, too, so it's more a UI thing. Lukasz Lenart wrote: 2009/7/17 mathias-ewald nitehoax...@gmx.net: I want to round a value during an interation: Maybe it will be better to prepare a list on server side with rounded values and iterate over them? Regards -- Lukasz http://www.lenart.org.pl/ http://dailylog.lenart.org.pl/ Pablo Picasso - Computers are useless. They can only give you answers. - http://www.brainyquote.com/quotes/authors/p/pablo_picasso.html - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org -- View this message in context: http://www.nabble.com/in-JSP%3A-rounding-values-tp24528871p24530364.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: in JSP: rounding values
Okay, it was just my understanding of the whole thing. I will do as you suggested. cu Lukasz Lenart wrote: 2009/7/17 mathias-ewald nitehoax...@gmx.net: I don't think so - I want the exact value to be shown, too, so it's more a UI thing. As you thing, but that's the business logic and even such simple operation shouldn't be performed in UI. Maybe it will be simpler to create TransferObject with original value and rounded value and put it on the list. Regards -- Lukasz http://www.lenart.org.pl/ http://dailylog.lenart.org.pl/ Pablo Picasso - Computers are useless. They can only give you answers. - http://www.brainyquote.com/quotes/authors/p/pablo_picasso.html - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org -- View this message in context: http://www.nabble.com/in-JSP%3A-rounding-values-tp24528871p24531973.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Working with dynamic forms
Hi, I have a Category business object looking like this: -- public class Category { private Category parent; private SetCategory children; //... } -- I have a form that allows me to edit in information about a different object. This object is linked to zero, one or more Category objects. What's a good way to display this? I though of check boxes. The check boxes must be checked if the object is already attached to that Category. To me this seems to be kinda impossible right now. Any suggestions? cu mathias -- View this message in context: http://www.nabble.com/Working-with-dynamic-forms-tp24532787p24532787.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
URL to underlying action
Hi, is there a way to create a URL (like s:url) to the Action that called a JSP file? I would like to reuse some code like forms and other stuff cu mathias -- View this message in context: http://www.nabble.com/URL-to-underlying-action-tp24514500p24514500.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: URL to underlying action
Works - thx. I should have seen that in the doc though ^^ Nils-Helge Garli wrote: Try using the url tag without specifying value or action. Nils-H Den 16. juli. 2009 kl. 13.14 skrev mathias-ewald nitehoax...@gmx.net: Hi, is there a way to create a URL (like s:url) to the Action that called a JSP file? I would like to reuse some code like forms and other stuff cu mathias -- View this message in context: http://www.nabble.com/URL-to-underlying-action-tp24514500p24514500.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org -- View this message in context: http://www.nabble.com/URL-to-underlying-action-tp24514500p24521180.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Login with Struts2
Hi, I am trying to implement a login mechanism. I will now explain what I did and what error I get but in case there is a more sophisticated way to do that - please tell me! I created a BaseAction which is the parent of all my Actions. The BaseAction is supposed to be responsible for displaying a login page if there is no User object in session scope. Then the login form should put the username and password into the BaseAction. The BaseAction then tries to find a match in the database and places the User object into session scope: - public abstract class BaseAction { private String username; private String password; protected Log log; private Boolean loginStatus; public String execute() { if(log == null) { log = LogFactory.getLog(getClass()); } if(isProtected()) { MapString, Object session = ActionContext.getContext().getSession(); Object o = session.get(user); if(o instanceof User) { loginStatus = true; } else { return login; } } return executeAction(); } public abstract String executeAction(); public abstract Boolean isProtected(); public Boolean getLoginStatus() { return loginStatus; } public void setLoginStatus(Boolean loginStatus) { this.loginStatus = loginStatus; } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } } - An Action that wants to be password protected must implement #isProtected() to return true. This is my JSP file that is shown if #isProtected() == true and there's no User in session scope: - ... s:form s:textfield label=Username name=userData.username/s:textfield s:password label=Password name=userData.password/s:password s:submit/s:submit /s:form ... - This is the error I get - 20:35:42,179 WARN OgnlValueStack:49 - Error setting value ognl.OgnlException: target is null for setProperty(null, password, [Ljava.lang.String;@1f22dad5) at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:1651) at ognl.ASTProperty.setValueBody(ASTProperty.java:101) at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:177) at ognl.SimpleNode.setValue(SimpleNode.java:246) at ognl.ASTChain.setValueBody(ASTChain.java:172) at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:177) at ognl.SimpleNode.setValue(SimpleNode.java:246) at ognl.Ognl.setValue(Ognl.java:476) ... - Why is that happening? cu mathias -- View this message in context: http://www.nabble.com/Login-with-Struts2-tp24522078p24522078.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
in JSP: rounding values
Hi, I want to round a value during an interation: -- s:sort comparator=mapComparator source=statsMap s:iterator tr tds:property value=key.name /br(Min: s:property value=key.min /, Max: s:property value=key.max /)/td td s:set name=average value=value.average / % int val = 0; % s:property value=val / /td /tr /s:iterator /s:sort -- As you can see, I iterate over a map. The value element of the map contains a field named averate. This average is a Float which I want to round (Math.round()). I don't really know how to do that. I can find out how to access the value from within % %. Once I have access to it, how can I print that value? I never actually used % % tags. Or ist there an easier way? The whole idea if this code is to display ratings of serveral criteria where a rating has a minimum value of key.min, a maximum of key.max and the average rating is value.average. I want these values to be displays using star icons. I am telling you this hoping there is a much easier way ;) cu mathias -- View this message in context: http://www.nabble.com/in-JSP%3A-rounding-values-tp24528871p24528871.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org