Variable substitution at resource property file

2013-12-27 Thread Albert Kao
I like to do variable substitution at the resource property file.
I had tried this:
Resource property file:
common.name=What is the name?
page.name.01=${common.name}

Jsp file:
bean:message key=page.name.01 /

The browser displayed the desired message properly.
i.e.
What is the name? is displayed properly.
However, there was runtime error at the weblogic console:
can't parse argument number common.name
java.lang.IllegalArgumentException: can't parse argument number common.name
at java.text.MessageFormat.makeFormat(MessageFormat.java:1339)
at java.text.MessageFormat.applyPattern(MessageFormat.java:458)
at java.text.MessageFormat.init(MessageFormat.java:350)
at org.apache.struts.util.MessageResources.getMessage(MessageResources.java:302)
at org.apache.struts.taglib.TagUtils.message(TagUtils.java:953)
at org.apache.struts.taglib.bean.MessageTag.doStartTag(MessageTag.java:221)
at jsp_servlet._prot._pages.__vbi_01._jsp__tag14(__vbi_01.java:711)
at jsp_servlet._prot._pages.__vbi_01._jsp__tag2(__vbi_01.java:281)
at jsp_servlet._prot._pages.__vbi_01._jspService(__vbi_01.java:133)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:34)
at 
weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at 
weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:301)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:184)
at 
weblogic.servlet.internal.RequestDispatcherImpl.invokeServlet(RequestDispatcherImpl.java:529)
at 
weblogic.servlet.internal.RequestDispatcherImpl.include(RequestDispatcherImpl.java:447)
at weblogic.servlet.jsp.PageContextImpl.include(PageContextImpl.java:163)
at org.apache.struts.tiles.TilesUtilImpl.doInclude(TilesUtilImpl.java:135)
at org.apache.struts.tiles.TilesUtil.doInclude(TilesUtil.java:149)
at org.apache.struts.tiles.taglib.InsertTag.doInclude(InsertTag.java:761)
at 
org.apache.struts.tiles.taglib.InsertTag$InsertHandler.doEndTag(InsertTag.java:893)
at org.apache.struts.tiles.taglib.InsertTag.doEndTag(InsertTag.java:462)


Please help.
Thanks.


variable substitution in html:textarea

2014-10-30 Thread Albert Kao
How to do variable substitution in html:textarea? e.g. Java code
package util;
public interface Literals {    public static final String LAST_NAME = 
lastName;}
my.jsp
%@ page import=util.Literals %

html:textarea rows=20 cols=100 property=buffer 
value='%=Literals.LAST_NAME %'/html:textarea

I try to make lastName to appear at my.jsp but get the following 
instead:%=Literals.LAST_NAME %


replace Java scriptlets in JSP page

2014-12-29 Thread Albert Kao
The following Java scriptlet code in a Struts jsp is working fine. 
However, is it possible to change the jsp code so as to remove all the Java 
scriptlet codes? 

The .jsp code is like this:%
  HttpSession httpSession = request.getSession(true);
  MyClient myClient = (MyClient)httpSession.getAttribute(MyConst.MY_CLIENT);
%
logic:iterate id=pOwnersID name=%=MyConst.MY_CLIENT%
  property=pOwners length=%=MyConst.MY_OWNER_MAX% indexId=index
  %
    pageContext.setAttribute(requiredIndex, myClient.getRequiredIndex(index), 
PageContext.PAGE_SCOPE);
  %
  h2
    bean:message key=common.owner.label / %= myClient.getNumber(index) %
  /h2

  div
    logic:lessThan name=requiredIndex value=1
  label for='%=lastName + index%' class=required
    bean:message key=common.lastName.label /
    jsp:include page=/pages/common/required.jsp flush=true /
  /label
    /logic:lessThan
    logic:greaterEqual name=requiredIndex value=1
  label for=%=lastName + index%
    bean:message key=common.lastName.label /
  /label
    /logic:greaterEqual
    html:text styleClass=form-control
  styleId='%=lastName + index%' name=inputForm
  property='%=myForm.pOwners[+index+].lastName%' size=62
  maxlength=30 /
  /div
/logic:iterate


The java code is like this:public class Owner implements java.io.Serializable {
    private static final long serialVersionUID = 7920764268572909394L;
    private String lastName;
    private String ownershipCode;
    //...
    
    public Owner() {
    }

    // getter and setters
    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    //...
    public Integer getRequiredIndex(Integer index) {
        Integer requiredIndex = index;
        if (OWNRSHP_PARTNER.equals(ownershipCode)) {
            requiredIndex = requiredIndex - 1;
        }
        return requiredIndex;    
    }

    public String getNumber(Integer index) {
        String number = Integer.toString(index + 1);
        if (OWNRSHP_SOLE.equals(ownershipCode)) {
            number = ;
        } 
        return number;    
    }
}



Re: replace Java scriptlets in JSP page

2014-12-30 Thread Albert Kao
I am using struts 1 because of company policy.
 

 On Monday, December 29, 2014 11:20 PM, Sreekanth S. Nair 
sreekanth.n...@egovernments.org wrote:
   

 Sure you can, please if you are using struts2 please read these tutorials
Struts2 Tag lesson
http://www.tutorialspoint.com/struts_2/
or
http://struts.apache.org/docs/tag-reference.html

and a bit of JSP EL
http://www.tutorialspoint.com/jsp/jsp_expression_language.htm




-- 
Thanks  Regards

Sreekanth S Nair
Java Developer
---
eGovernments Foundation http://www.egovernments.org
Ph : 9980078913
---
http://in.linkedin.com/pub/sreekanth-s-nair/b/946/5a0/
https://github.com/sreekanthsnair  sreekanthsn...@hotmail.co.uk
sreekanths...@gmail.com
---

On Tue, Dec 30, 2014 at 4:47 AM, Albert Kao albertk...@yahoo.ca wrote:

 The following Java scriptlet code in a Struts jsp is working fine.
 However, is it possible to change the jsp code so as to remove all
 the Java scriptlet codes?

 The .jsp code is like this:%
  HttpSession httpSession = request.getSession(true);
  MyClient myClient =
 (MyClient)httpSession.getAttribute(MyConst.MY_CLIENT);
 %
 logic:iterate id=pOwnersID name=%=MyConst.MY_CLIENT%
  property=pOwners length=%=MyConst.MY_OWNER_MAX% indexId=index
  %
    pageContext.setAttribute(requiredIndex,
 myClient.getRequiredIndex(index), PageContext.PAGE_SCOPE);
  %
  h2
    bean:message key=common.owner.label / %=
 myClient.getNumber(index) %
  /h2

  div
    logic:lessThan name=requiredIndex value=1
      label for='%=lastName + index%' class=required
        bean:message key=common.lastName.label /
        jsp:include page=/pages/common/required.jsp flush=true /
      /label
    /logic:lessThan
    logic:greaterEqual name=requiredIndex value=1
      label for=%=lastName + index%
        bean:message key=common.lastName.label /
      /label
    /logic:greaterEqual
    html:text styleClass=form-control
      styleId='%=lastName + index%' name=inputForm
      property='%=myForm.pOwners[+index+].lastName%' size=62
      maxlength=30 /
  /div
 /logic:iterate


 The java code is like this:public class Owner implements
 java.io.Serializable {
    private static final long serialVersionUID = 7920764268572909394L;
    private String lastName;
    private String ownershipCode;
    //...

    public Owner() {
    }

    // getter and setters
    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    //...
    public Integer getRequiredIndex(Integer index) {
        Integer requiredIndex = index;
        if (OWNRSHP_PARTNER.equals(ownershipCode)) {
            requiredIndex = requiredIndex - 1;
        }
        return requiredIndex;
    }

    public String getNumber(Integer index) {
        String number = Integer.toString(index + 1);
        if (OWNRSHP_SOLE.equals(ownershipCode)) {
            number = ;
        }
        return number;
    }
 }




   

org.apache.jasper.JasperException struts-examples-master crud

2017-10-13 Thread albert kao
I downloaded struts-examples-master.zip from
https://github.com/apache/struts-examples.
Unzip it and run mvn.

# mvn -version
Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426;
2017-04-03T15:39:06-04:00)
Maven home: /home/alkao/maven/apache-maven-3.5.0
Java version: 1.8.0_144, vendor: Oracle Corporation
Java home: /home/alkao/jdk/jdk1.8.0_144/jre
Default locale: en_CA, platform encoding: UTF-8
OS name: "linux", version: "4.4.0-21-generic", arch: "i386", family: "unix"


$ mvn -e clean package

Copy crud-1.0-SNAPSHOT.war to Apache TomEE:
# cp ~/Struts2/struts-examples-master/crud/target/crud-1.0-SNAPSHOT.war
$CATALINA_HOME/webapps/.


In a browser accessing URL:
http://localhost:8080/crud-1.0-SNAPSHOT/index.jsp


which display:
"Welcome To Struts 2!

List People"


Then clicking the 'List People' link displayed:

Struts Problem Report

Struts has detected an unhandled exception:

Messages:
/WEB-INF/jsp/persons.jsp (line: 13, column: 8) Attribute id invalid for tag
url according to TLD
File: org/apache/jasper/compiler/DefaultErrorHandler.java
Line number: 41
Stacktraces

org.apache.jasper.JasperException: /WEB-INF/jsp/persons.jsp (line: 13,
column: 8) Attribute id invalid for tag url according to TLD

org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:41)

org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:291)

org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:114)

org.apache.jasper.compiler.Validator$ValidateVisitor.checkXmlAttributes(Validator.java:1266)

org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:879)
org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1545)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2392)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2444)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2450)
org.apache.jasper.compiler.Node$Root.accept(Node.java:471)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2392)

org.apache.jasper.compiler.Validator.validateExDirectives(Validator.java:1853)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:219)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:372)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:349)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:333)

org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:600)

org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:368)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)

org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)

org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)

org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:726)

org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:469)

org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:394)

org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:311)

org.apache.struts2.result.ServletDispatcherResult.doExecute(ServletDispatcherResult.java:173)

org.apache.struts2.result.StrutsResultSupport.execute(StrutsResultSupport.java:208)

com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:373)

com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:277)

com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.doIntercept(ConversionErrorInterceptor.java:139)

com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)

com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:247)

com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:134)

com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)

com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:247)

com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:134)

com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)

com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:247)

org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:69)


Clicking helloworld link got java.lang.NoSuchMethodError: org.apache.commons.lang3.reflect.MethodUtils.getAnnotation

2017-08-26 Thread albert kao
I downloaded struts-examples-master.zip from
https://github.com/apache/struts-examples.
Unzip it and run mvn.

# mvn -version
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5;
2015-11-10T11:41:47-05:00)
Maven home: /home/alkao/maven/apache-maven-3.3.9
Java version: 1.8.0_131, vendor: Oracle Corporation
Java home: /home/alkao/jdk/jdk1.8.0_131/jre
Default locale: en_CA, platform encoding: UTF-8
OS name: "linux", version: "4.4.0-21-generic", arch: "i386", family: "unix"


$ mvn -e clean package
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model
for org.apache.struts:annotations:war:1.0.0
[WARNING] The expression ${artifactId} is deprecated. Please use
${project.artifactId} instead.
[WARNING]
...
[WARNING]
[WARNING] It is highly recommended to fix these problems because they
threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support
building such malformed projects.
[WARNING]
[INFO]

[INFO] Reactor Build Order:
[INFO]
...
[INFO] Building Action chaining 1.0-SNAPSHOT
[INFO]

Downloading:
https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-compiler-plugin/3.3/maven-compiler-plugin-3.3.pom
Downloaded:
https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-compiler-plugin/3.3/maven-compiler-plugin-3.3.pom
(12 KB at 21.7 KB/sec)
Downloading:
https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-plugins/27/maven-plugins-27.pom
Downloaded:
https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-plugins/27/maven-plugins-27.pom
(0 B at 0.0 KB/sec)
Downloading:
https://repo.maven.apache.org/maven2/org/apache/maven/maven-parent/26/maven-parent-26.pom
Downloaded:
https://repo.maven.apache.org/maven2/org/apache/maven/maven-parent/26/maven-parent-26.pom
(0 B at 0.0 KB/sec)
Downloading:
https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-compiler-plugin/3.3/maven-compiler-plugin-3.3.jar
Downloaded:
https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-compiler-plugin/3.3/maven-compiler-plugin-3.3.jar
(46 KB at 415.4 KB/sec)
Downloading:
https://repository.apache.org/content/groups/public/org/apache/struts/struts2-core/2.5.12/struts2-core-2.5.12.pom
Downloaded:
https://repository.apache.org/content/groups/public/org/apache/struts/struts2-core/2.5.12/struts2-core-2.5.12.pom
(17 KB at 30.1 KB/sec)
...
[INFO]

[INFO] BUILD SUCCESS
...



Copy hello-world.war to Apache TomEE:
# cp helloworld/target/hello-world.war $CATALINA_HOME/webapps/.


In a browser accessing URL:
http://localhost:8080/hello-world/index.jsp


which display:
"Welcome To Struts 2!

Hello World"



Then clicking the 'Hello World' link got the url:
http://localhost:8080/hello-world/hello.action;jsessionid=8EEA47306A76BAE87F665C6090D518E3


which display:
HTTP Status 500 - Filter execution threw an exception

type Exception report

message Filter execution threw an exception

description The server encountered an internal error that prevented it from
fulfilling this request.

exception

javax.servlet.ServletException: Filter execution threw an exception
root cause

java.lang.NoSuchMethodError:
org.apache.commons.lang3.reflect.MethodUtils.getAnnotation(Ljava/lang/reflect/Method;Ljava/lang/Class;ZZ)Ljava/lang/annotation/Annotation;
org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:47)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:247)
com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.doIntercept(ConversionErrorInterceptor.java:139)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:247)
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:134)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:247)
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:134)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:247)
com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:199)

Re: Clicking helloworld link got java.lang.NoSuchMethodError: org.apache.commons.lang3.reflect.MethodUtils.getAnnotation

2017-09-04 Thread albert kao
As per your instruction, modify catalina.sh:
JAVA_OPTS="$JAVA_OPTS
-Djava.protocol.handler.pkgs=org.apache.catalina.webresources
-XX:+TraceClassLoading -XX:+TraceClassUnloading"

$ catalina.sh run > my_tomcat.log 2>&1

my_tomcat.log:
[Loaded org.apache.commons.lang3.reflect.MethodUtils from
file:/home/alkao/tomee/apache-tomee-plus-7.0.3/lib/commons-lang3-3.5.jar]

Although I had done the following:
export
CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$HOME/Struts2/struts-2.5.12/lib:$CATALINA_HOME/lib:.

$ ls /home/alkao/Struts2/struts-2.5.12/lib/commons-lang3*
/home/alkao/Struts2/struts-2.5.12/lib/commons-lang3-3.6.jar

Therefore the helloworld link in index.jsp did not see the
/home/alkao/Struts2/struts-2.5.12/lib/commons-lang3-3.6.jar.


On Sat, Sep 2, 2017 at 2:46 PM, Yasser Zamani <yasser.zam...@live.com>
wrote:

> I did as you said and did not get any exception!
>
> Could you please add following line to catalina.bat:
>
> set "JAVA_OPTS=-XX:+TraceClassLoading -XX:+TraceClassUnloading"
>
> then:
>
> catalina.bat run > my_tomcat.log 2>&1
>
> then finally search my_tomcat.log for MethodUtils?
>
> I would like to see from where your tomcat load MethodUtils class!
>
>
> On 9/2/2017 7:06 PM, albert kao wrote:
> > My hello-world.war has the commons lang3 3.6:
> > hello-world/WEB-INF/lib
> > hello-world/WEB-INF/lib/commons-fileupload-1.3.3.jar
> > hello-world/WEB-INF/lib/ognl-3.1.12.jar
> > hello-world/WEB-INF/lib/struts2-core-2.5.12.jar
> > hello-world/WEB-INF/lib/freemarker-2.3.23.jar
> > hello-world/WEB-INF/lib/log4j-core-2.8.2.jar
> > hello-world/WEB-INF/lib/log4j-api-2.8.2.jar
> > hello-world/WEB-INF/lib/commons-io-2.4.jar
> > hello-world/WEB-INF/lib/javassist-3.20.0-GA.jar
> > hello-world/WEB-INF/lib/commons-lang3-3.6.jar
> >
> > However, the helloworld link in index.jsp did not see it.
> >
> >
> > On Sat, Aug 26, 2017 at 7:43 PM, Yasser Zamani <yasser.zam...@live.com>
> > wrote:
> >
> >> I checked it's codes and seems ok. It has a dependency to struts 2.5.12
> >> which has (not optional) dependency to commons lang3 3.6. So you should
> >> have commons lang3 3.6 in your war lib. Do you? Or maybe you have lower
> >> version of commons lang3 jar in your tomcat lib? Please check both.
> >>
> >> albert kao <albertk...@gmail.com> نوشت:
> >>
> >>> I downloaded struts-examples-master.zip from
> >>> https://github.com/apache/struts-examples.
> >>> Unzip it and run mvn.
> >>>
> >>> # mvn -version
> >>> Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5;
> >>> 2015-11-10T11:41:47-05:00)
> >>> Maven home: /home/alkao/maven/apache-maven-3.3.9
> >>> Java version: 1.8.0_131, vendor: Oracle Corporation
> >>> Java home: /home/alkao/jdk/jdk1.8.0_131/jre
> >>> Default locale: en_CA, platform encoding: UTF-8
> >>> OS name: "linux", version: "4.4.0-21-generic", arch: "i386", family:
> >> "unix"
> >>>
> >>>
> >>> $ mvn -e clean package
> >>> [INFO] Error stacktraces are turned on.
> >>> [INFO] Scanning for projects...
> >>> [WARNING]
> >>> [WARNING] Some problems were encountered while building the effective
> >> model
> >>> for org.apache.struts:annotations:war:1.0.0
> >>> [WARNING] The expression ${artifactId} is deprecated. Please use
> >>> ${project.artifactId} instead.
> >>> [WARNING]
> >>> ...
> >>> [WARNING]
> >>> [WARNING] It is highly recommended to fix these problems because they
> >>> threaten the stability of your build.
> >>> [WARNING]
> >>> [WARNING] For this reason, future Maven versions might no longer
> support
> >>> building such malformed projects.
> >>> [WARNING]
> >>> [INFO]
> >>> 
> 
> >>> [INFO] Reactor Build Order:
> >>> [INFO]
> >>> ...
> >>> [INFO] Building Action chaining 1.0-SNAPSHOT
> >>> [INFO]
> >>> 
> 
> >>> Downloading:
> >>> https://repo.maven.apache.org/maven2/org/apache/maven/
> >> plugins/maven-compiler-plugin/3.3/maven-compiler-plugin-3.3.pom
> >>> Downloaded:
> >>> https://repo.maven.apache.org/maven2/org/apache/maven/
> >> plugins/maven-compiler-plugin/3.3/maven-compiler-plugin-3

Re: Clicking helloworld link got java.lang.NoSuchMethodError: org.apache.commons.lang3.reflect.MethodUtils.getAnnotation

2017-09-02 Thread albert kao
My hello-world.war has the commons lang3 3.6:
hello-world/WEB-INF/lib
hello-world/WEB-INF/lib/commons-fileupload-1.3.3.jar
hello-world/WEB-INF/lib/ognl-3.1.12.jar
hello-world/WEB-INF/lib/struts2-core-2.5.12.jar
hello-world/WEB-INF/lib/freemarker-2.3.23.jar
hello-world/WEB-INF/lib/log4j-core-2.8.2.jar
hello-world/WEB-INF/lib/log4j-api-2.8.2.jar
hello-world/WEB-INF/lib/commons-io-2.4.jar
hello-world/WEB-INF/lib/javassist-3.20.0-GA.jar
hello-world/WEB-INF/lib/commons-lang3-3.6.jar

However, the helloworld link in index.jsp did not see it.


On Sat, Aug 26, 2017 at 7:43 PM, Yasser Zamani <yasser.zam...@live.com>
wrote:

> I checked it's codes and seems ok. It has a dependency to struts 2.5.12
> which has (not optional) dependency to commons lang3 3.6. So you should
> have commons lang3 3.6 in your war lib. Do you? Or maybe you have lower
> version of commons lang3 jar in your tomcat lib? Please check both.
>
> albert kao <albertk...@gmail.com> نوشت:
>
> >I downloaded struts-examples-master.zip from
> >https://github.com/apache/struts-examples.
> >Unzip it and run mvn.
> >
> ># mvn -version
> >Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5;
> >2015-11-10T11:41:47-05:00)
> >Maven home: /home/alkao/maven/apache-maven-3.3.9
> >Java version: 1.8.0_131, vendor: Oracle Corporation
> >Java home: /home/alkao/jdk/jdk1.8.0_131/jre
> >Default locale: en_CA, platform encoding: UTF-8
> >OS name: "linux", version: "4.4.0-21-generic", arch: "i386", family:
> "unix"
> >
> >
> >$ mvn -e clean package
> >[INFO] Error stacktraces are turned on.
> >[INFO] Scanning for projects...
> >[WARNING]
> >[WARNING] Some problems were encountered while building the effective
> model
> >for org.apache.struts:annotations:war:1.0.0
> >[WARNING] The expression ${artifactId} is deprecated. Please use
> >${project.artifactId} instead.
> >[WARNING]
> >...
> >[WARNING]
> >[WARNING] It is highly recommended to fix these problems because they
> >threaten the stability of your build.
> >[WARNING]
> >[WARNING] For this reason, future Maven versions might no longer support
> >building such malformed projects.
> >[WARNING]
> >[INFO]
> >
> >[INFO] Reactor Build Order:
> >[INFO]
> >...
> >[INFO] Building Action chaining 1.0-SNAPSHOT
> >[INFO]
> >
> >Downloading:
> >https://repo.maven.apache.org/maven2/org/apache/maven/
> plugins/maven-compiler-plugin/3.3/maven-compiler-plugin-3.3.pom
> >Downloaded:
> >https://repo.maven.apache.org/maven2/org/apache/maven/
> plugins/maven-compiler-plugin/3.3/maven-compiler-plugin-3.3.pom
> >(12 KB at 21.7 KB/sec)
> >Downloading:
> >https://repo.maven.apache.org/maven2/org/apache/maven/
> plugins/maven-plugins/27/maven-plugins-27.pom
> >Downloaded:
> >https://repo.maven.apache.org/maven2/org/apache/maven/
> plugins/maven-plugins/27/maven-plugins-27.pom
> >(0 B at 0.0 KB/sec)
> >Downloading:
> >https://repo.maven.apache.org/maven2/org/apache/maven/
> maven-parent/26/maven-parent-26.pom
> >Downloaded:
> >https://repo.maven.apache.org/maven2/org/apache/maven/
> maven-parent/26/maven-parent-26.pom
> >(0 B at 0.0 KB/sec)
> >Downloading:
> >https://repo.maven.apache.org/maven2/org/apache/maven/
> plugins/maven-compiler-plugin/3.3/maven-compiler-plugin-3.3.jar
> >Downloaded:
> >https://repo.maven.apache.org/maven2/org/apache/maven/
> plugins/maven-compiler-plugin/3.3/maven-compiler-plugin-3.3.jar
> >(46 KB at 415.4 KB/sec)
> >Downloading:
> >https://repository.apache.org/content/groups/public/org/
> apache/struts/struts2-core/2.5.12/struts2-core-2.5.12.pom
> >Downloaded:
> >https://repository.apache.org/content/groups/public/org/
> apache/struts/struts2-core/2.5.12/struts2-core-2.5.12.pom
> >(17 KB at 30.1 KB/sec)
> >...
> >[INFO]
> >
> >[INFO] BUILD SUCCESS
> >...
> >
> >
> >
> >Copy hello-world.war to Apache TomEE:
> ># cp helloworld/target/hello-world.war $CATALINA_HOME/webapps/.
> >
> >
> >In a browser accessing URL:
> >http://localhost:8080/hello-world/index.jsp
> >
> >
> >which display:
> >"Welcome To Struts 2!
> >
> >Hello World"
> >
> >
> >
> >Then clicking the 'Hello World' link got the url:
> >http://localhost:8080/hel

Re: Clicking helloworld link got java.lang.NoSuchMethodError: org.apache.commons.lang3.reflect.MethodUtils.getAnnotation

2017-09-05 Thread albert kao
I tried
export
CLASSPATH=$JAVA_HOME/lib:$HOME/Struts2/struts-2.5.12/lib:$CATALINA_HOME/lib:$CLASSPATH:.

but the helloworld link in index.jsp still did not see the
/home/alkao/Struts2/struts-2.5.12/lib/commons-lang3-3.6.jar.


my_tomcat.log did not have this line any more
[Loaded org.apache.commons.lang3.reflect.MethodUtils from
file:/home/alkao/tomee/apache-tomee-plus-7.0.3/lib/commons-lang3-3.5.jar]


It had lines such as:
[Loaded org.apache.commons.lang3.text.StrLookup from
file:/home/alkao/tomee/apache-tomee-plus-7.0.3/lib/commons-lang3-3.5.jar]
[Loaded org.apache.commons.lang3.CharSequenceUtils from
file:/home/alkao/tomee/apache-tomee-plus-7.0.3/lib/commons-lang3-3.5.jar]
...


On Mon, Sep 4, 2017 at 1:30 PM, Yasser Zamani <yasser.zam...@live.com>
wrote:

> >> Although I had done the following:
> >> export
> >> CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$HOME/Struts2/struts-
> 2.5.12/lib:$CATALINA_HOME/lib:.
>
> If you would like to solve it like above, I think you may try below
> instead ($CLASSPATH at end):
>
> export
> CLASSPATH=$JAVA_HOME/lib:$HOME/Struts2/struts-2.5.12/
> lib:$CATALINA_HOME/lib:.:$CLASSPATH
>
> On 9/4/2017 5:24 PM, albert kao wrote:
> > As per your instruction, modify catalina.sh:
> > JAVA_OPTS="$JAVA_OPTS
> > -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
> > -XX:+TraceClassLoading -XX:+TraceClassUnloading"
> >
> > $ catalina.sh run > my_tomcat.log 2>&1
> >
> > my_tomcat.log:
> > [Loaded org.apache.commons.lang3.reflect.MethodUtils from
> > file:/home/alkao/tomee/apache-tomee-plus-7.0.3/lib/commons-
> lang3-3.5.jar]
> >
> > Although I had done the following:
> > export
> > CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$HOME/Struts2/struts-
> 2.5.12/lib:$CATALINA_HOME/lib:.
> >
> > $ ls /home/alkao/Struts2/struts-2.5.12/lib/commons-lang3*
> > /home/alkao/Struts2/struts-2.5.12/lib/commons-lang3-3.6.jar
> >
> > Therefore the helloworld link in index.jsp did not see the
> > /home/alkao/Struts2/struts-2.5.12/lib/commons-lang3-3.6.jar.
> >
> >
> > On Sat, Sep 2, 2017 at 2:46 PM, Yasser Zamani <yasser.zam...@live.com>
> > wrote:
> >
> >> I did as you said and did not get any exception!
> >>
> >> Could you please add following line to catalina.bat:
> >>
> >> set "JAVA_OPTS=-XX:+TraceClassLoading -XX:+TraceClassUnloading"
> >>
> >> then:
> >>
> >> catalina.bat run > my_tomcat.log 2>&1
> >>
> >> then finally search my_tomcat.log for MethodUtils?
> >>
> >> I would like to see from where your tomcat load MethodUtils class!
> >>
> >>
> >> On 9/2/2017 7:06 PM, albert kao wrote:
> >>> My hello-world.war has the commons lang3 3.6:
> >>> hello-world/WEB-INF/lib
> >>> hello-world/WEB-INF/lib/commons-fileupload-1.3.3.jar
> >>> hello-world/WEB-INF/lib/ognl-3.1.12.jar
> >>> hello-world/WEB-INF/lib/struts2-core-2.5.12.jar
> >>> hello-world/WEB-INF/lib/freemarker-2.3.23.jar
> >>> hello-world/WEB-INF/lib/log4j-core-2.8.2.jar
> >>> hello-world/WEB-INF/lib/log4j-api-2.8.2.jar
> >>> hello-world/WEB-INF/lib/commons-io-2.4.jar
> >>> hello-world/WEB-INF/lib/javassist-3.20.0-GA.jar
> >>> hello-world/WEB-INF/lib/commons-lang3-3.6.jar
> >>>
> >>> However, the helloworld link in index.jsp did not see it.
> >>>
> >>>
> >>> On Sat, Aug 26, 2017 at 7:43 PM, Yasser Zamani <yasser.zam...@live.com
> >
> >>> wrote:
> >>>
> >>>> I checked it's codes and seems ok. It has a dependency to struts
> 2.5.12
> >>>> which has (not optional) dependency to commons lang3 3.6. So you
> should
> >>>> have commons lang3 3.6 in your war lib. Do you? Or maybe you have
> lower
> >>>> version of commons lang3 jar in your tomcat lib? Please check both.
> >>>>
> >>>> albert kao <albertk...@gmail.com> نوشت:
> >>>>
> >>>>> I downloaded struts-examples-master.zip from
> >>>>> https://github.com/apache/struts-examples.
> >>>>> Unzip it and run mvn.
> >>>>>
> >>>>> # mvn -version
> >>>>> Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5;
> >>>>> 2015-11-10T11:41:47-05:00)
> >>>>> Maven home: /home/alkao/maven/apache-maven-3.3.9
> >>>>> Java version: 1.8.0_131, vendor: Oracle Corporation
> >>>>> Java home: /ho

Re: NullPointerException - com.opensymphony.xwork2.util.FileManager$FileRevision.needsReloading(FileManager.java:209) of "Apache Struts 2 Web Application Development" book

2017-11-13 Thread albert kao
As per your suggestion, changing struts2 version to 2.1.8 fix the problem.
Thanks!

On Sun, Nov 12, 2017 at 12:29 PM, Yasser Zamani <yasser.zam...@live.com>
wrote:

>
>
> On 11/12/2017 2:28 AM, albert kao wrote:
> > java.lang.NullPointerException
> > com.opensymphony.xwork2.util.FileManager$FileRevision.
> needsReloading(FileManager.java:209)
>
> I just googled "needsReloading(FileManager.java:209)" and found [1] :)
> it seems has been a bug and has fixed in 2.1.8.
>
> [1] https://issues.apache.org/jira/browse/WW-2956
>
> -
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>


NullPointerException - com.opensymphony.xwork2.util.FileManager$FileRevision.needsReloading(FileManager.java:209) of "Apache Struts 2 Web Application Development" book

2017-11-11 Thread albert kao
I downloaded the source code of the book "Apache Struts 2 Web Application
Development" by Dave Newton from the
https://www.packtpub.com/books/content/support.

Chapter 2 had compile error with Apache Maven 3.5.0.
$ mvn -version
Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426;
2017-04-03T15:39:06-04:00)
Maven home: /home/alkao/maven/apache-maven-3.5.0
Java version: 1.8.0_144, vendor: Oracle Corporation
Java home: /home/alkao/jdk/jdk1.8.0_144/jre
Default locale: en_CA, platform encoding: UTF-8
OS name: "linux", version: "4.4.0-21-generic", arch: "i386", family: "unix"

To fix it, I removed just the  tag in pom.xml.
Then run mvn:
$ cd
/home/alkao/Struts2/Apache_Struts_2_Web_Application_Development/ch02/sanity
$ mvn clean package

Running wildfly-10.1.0.Final:
$ JBOSS_HOME/bin/standalone.sh
$ jboss-cli.sh --connect --command="deploy
/home/alkao/Struts2/Apache_Struts_2_Web_Application_Development/ch02/sanity/target/ch02-sanity-1.0.war
--force"

Running these 3 http links resulted in the same error in the web browser
below.
Please help. Thanks.
http://localhost:8080/ch02-sanity-1.0/index.html
http://localhost:8080/ch02-sanity-1.0/sanity.jsp
http://localhost:8080/ch02-sanity-1.0/sanity.action




Error processing request
Context Path:
/ch02-convention-1.0

Servlet Path:
/index.html

Path Info:
null

Query String:
null

Stack Trace
java.lang.NullPointerException
com.opensymphony.xwork2.util.FileManager$FileRevision.needsReloading(FileManager.java:209)
com.opensymphony.xwork2.util.FileManager.fileNeedsReloading(FileManager.java:60)
com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.needsReload(XmlConfigurationProvider.java:325)
org.apache.struts2.config.StrutsXmlConfigurationProvider.needsReload(StrutsXmlConfigurationProvider.java:168)
com.opensymphony.xwork2.config.ConfigurationManager.conditionalReload(ConfigurationManager.java:220)
com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:61)
org.apache.struts2.dispatcher.Dispatcher.getContainer(Dispatcher.java:774)
org.apache.struts2.dispatcher.ng.InitOperations.initStaticContentLoader(InitOperations.java:77)
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:49)
io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:111)
org.wildfly.extension.undertow.security.RunAsLifecycleInterceptor.init(RunAsLifecycleInterceptor.java:84)
io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:97)
io.undertow.servlet.core.ManagedFilter.createFilter(ManagedFilter.java:80)
io.undertow.servlet.core.ManagedFilter.getFilter(ManagedFilter.java:66)
io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)
io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292)

Re: NullPointerException - com.opensymphony.xwork2.util.FileManager$FileRevision.needsReloading(FileManager.java:209) of "Apache Struts 2 Web Application Development" book

2017-11-12 Thread albert kao
struts2 version: 2.1.6

On Sat, Nov 11, 2017 at 9:47 PM, Dave Newton <davelnew...@gmail.com> wrote:

> What version of Struts 2 are you attempting to use?
>
> On Sat, Nov 11, 2017 at 5:58 PM albert kao <albertk...@gmail.com> wrote:
>
> > I downloaded the source code of the book "Apache Struts 2 Web Application
> > Development" by Dave Newton from the
> > https://www.packtpub.com/books/content/support.
> >
> > Chapter 2 had compile error with Apache Maven 3.5.0.
> > $ mvn -version
> > Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426;
> > 2017-04-03T15:39:06-04:00)
> > Maven home: /home/alkao/maven/apache-maven-3.5.0
> > Java version: 1.8.0_144, vendor: Oracle Corporation
> > Java home: /home/alkao/jdk/jdk1.8.0_144/jre
> > Default locale: en_CA, platform encoding: UTF-8
> > OS name: "linux", version: "4.4.0-21-generic", arch: "i386", family:
> "unix"
> >
> > To fix it, I removed just the  tag in pom.xml.
> > Then run mvn:
> > $ cd
> > /home/alkao/Struts2/Apache_Struts_2_Web_Application_
> Development/ch02/sanity
> > $ mvn clean package
> >
> > Running wildfly-10.1.0.Final:
> > $ JBOSS_HOME/bin/standalone.sh
> > $ jboss-cli.sh --connect --command="deploy
> >
> > /home/alkao/Struts2/Apache_Struts_2_Web_Application_
> Development/ch02/sanity/target/ch02-sanity-1.0.war
> > --force"
> >
> > Running these 3 http links resulted in the same error in the web browser
> > below.
> > Please help. Thanks.
> > http://localhost:8080/ch02-sanity-1.0/index.html
> > http://localhost:8080/ch02-sanity-1.0/sanity.jsp
> > http://localhost:8080/ch02-sanity-1.0/sanity.action
> >
> >
> >
> >
> > Error processing request
> > Context Path:
> > /ch02-convention-1.0
> >
> > Servlet Path:
> > /index.html
> >
> > Path Info:
> > null
> >
> > Query String:
> > null
> >
> > Stack Trace
> > java.lang.NullPointerException
> >
> > com.opensymphony.xwork2.util.FileManager$FileRevision.
> needsReloading(FileManager.java:209)
> >
> > com.opensymphony.xwork2.util.FileManager.fileNeedsReloading(
> FileManager.java:60)
> >
> > com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.
> needsReload(XmlConfigurationProvider.java:325)
> >
> > org.apache.struts2.config.StrutsXmlConfigurationProvider.needsReload(
> StrutsXmlConfigurationProvider.java:168)
> >
> > com.opensymphony.xwork2.config.ConfigurationManager.conditionalReload(
> ConfigurationManager.java:220)
> >
> > com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(
> ConfigurationManager.java:61)
> > org.apache.struts2.dispatcher.Dispatcher.getContainer(
> Dispatcher.java:774)
> >
> > org.apache.struts2.dispatcher.ng.InitOperations.initStaticContentLoader(
> InitOperations.java:77)
> >
> > org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.
> init(StrutsPrepareAndExecuteFilter.java:49)
> >
> > io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(
> LifecyleInterceptorInvocation.java:111)
> >
> > org.wildfly.extension.undertow.security.RunAsLifecycleInterceptor.init(
> RunAsLifecycleInterceptor.java:84)
> >
> > io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(
> LifecyleInterceptorInvocation.java:97)
> > io.undertow.servlet.core.ManagedFilter.createFilter(
> ManagedFilter.java:80)
> > io.undertow.servlet.core.ManagedFilter.getFilter(ManagedFilter.java:66)
> > io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
> >
> > io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.
> doFilter(FilterHandler.java:131)
> >
> > io.undertow.servlet.handlers.FilterHandler.handleRequest(
> FilterHandler.java:84)
> >
> > io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.
> handleRequest(ServletSecurityRoleHandler.java:62)
> >
> > io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(
> ServletDispatchingHandler.java:36)
> >
> > org.wildfly.extension.undertow.security.SecurityContextAssociationHand
> ler.handleRequest(SecurityContextAssociationHandler.java:78)
> >
> > io.undertow.server.handlers.PredicateHandler.handleRequest(
> PredicateHandler.java:43)
> >
> > io.undertow.servlet.handlers.security.SSLInformationAssociationHandl
> er.handleRequest(SSLInformationAssociationHandler.java:131)
> >
> > io.undertow.servlet.handlers.security.ServletAuthenti

scopedModelDriven and ScopedModelDrivenInterceptor

2017-11-05 Thread albert kao
I am a Struts2 beginner.
I saw the scopedModelDriven and ScopedModelDrivenInterceptor mentioned in
chapter 14 "Migration from Struts Classic" in the "Struts 2 in  Action"
book by "Donald Brown, ...".

The Struts2 documentation said:

"public interface ScopedModelDriven
extends ModelDriven


Adds the ability to set a model, probably retrieved from a given state."

Are scopedModelDriven and ScopedModelDrivenInterceptor used for mainly
for "Migration
from Struts Classic"?
If not, please provide more explanation and source code examples.
Thanks.


Error on line 25, column 9 in template/simple/radiomap.ftl

2017-11-06 Thread albert kao
My program below caused FreeMarker template error .
Please help.
Thanks.

Java:
import java.util.ArrayList;
import java.util.List;
tcma
import com.mkyong.common.model.Language;
import com.opensymphony.xwork2.ActionSupport;

public class RadioButtonAction extends ActionSupport{
private List myGoodList;
public RadioButtonAction(){
myGoodList = new ArrayList();
myGoodList.add("myGoodList3");
myGoodList.add("myGoodList2");
myGoodList.add("myGoodList1");

}
public List getMyGoodList() {
return myGoodList;
}

public String execute() {
return SUCCESS;
}
public String display() {
return NONE;
}

}


jsp:
<%@ taglib prefix="s" uri="/struts-tags" %>





Struts 2 radio button & select  example






















Struts 2 radio button & select example
selectedId:
*FreeMarker template error!*



Error on line 25, column 9 in template/simple/radiomap.ftl
stack.findValue(parameters.listKey) is undefined.
It cannot be assigned to itemKey
The problematic instruction:
--
== assignment: itemKey=stack.findValue(parameters.listKey) [on
line 25, column 9 in template/simple/radiomap.ftl]
 in user-directive s.iterator [on line 23, column 1 in
template/simple/radiomap.ftl]
 in include "/${parameters.templateDir}/simple/radiomap.ftl" [on line
25, column 1 in template/xhtml/radiomap.ftl]
--

Java backtrace for programmers:
--
freemarker.core.InvalidReferenceException: Error on line 25, column 9
in template/simple/radiomap.ftl
stack.findValue(parameters.listKey) is undefined.
It cannot be assigned to itemKey
at freemarker.core.Assignment.accept(Assignment.java:111)
at freemarker.core.Environment.visit(Environment.java:209)
at freemarker.core.IfBlock.accept(IfBlock.java:82)
at freemarker.core.Environment.visit(Environment.java:209)
at freemarker.core.MixedContent.accept(MixedContent.java:92)
at freemarker.core.Environment.visit(Environment.java:209)
at freemarker.core.Environment.visit(Environment.java:298)
at freemarker.core.UnifiedCall.accept(UnifiedCall.java:130)
at freemarker.core.Environment.visit(Environment.java:209)
at freemarker.core.MixedContent.accept(MixedContent.java:92)
at freemarker.core.Environment.visit(Environment.java:209)
at freemarker.core.Environment.include(Environment.java:1482)
at freemarker.core.Include.accept(Include.java:169)
at freemarker.core.Environment.visit(Environment.java:209)
at freemarker.core.MixedContent.accept(MixedContent.java:92)
at freemarker.core.Environment.visit(Environment.java:209)
at freemarker.core.Environment.process(Environment.java:189)
at freemarker.template.Template.process(Template.java:237)
at 
org.apache.struts2.components.template.FreemarkerTemplateEngine.renderTemplate(FreemarkerTemplateEngine.java:182)
at org.apache.struts2.components.UIBean.mergeTemplate(UIBean.java:559)
at org.apache.struts2.components.UIBean.end(UIBean.java:513)
at 
org.apache.struts2.views.jsp.ComponentTagSupport.doEndTag(ComponentTagSupport.java:42)
at 
org.apache.jsp.pages.radiobutton_jsp._jspx_meth_s_005fradio_005f0(radiobutton_jsp.java:248)
at 
org.apache.jsp.pages.radiobutton_jsp._jspx_meth_s_005fiterator_005f0(radiobutton_jsp.java:212)
at 
org.apache.jsp.pages.radiobutton_jsp._jspx_meth_s_005fform_005f0(radiobutton_jsp.java:161)
at 
org.apache.jsp.pages.radiobutton_jsp._jspService(radiobutton_jsp.java:111)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at 
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:433)
at 
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:402)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:346)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at 
io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
at 
io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:81)
at 
io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
at io.undertow.jsp.JspFileHandler.handleRequest(JspFileHandler.java:32)
at 
io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
at 
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at 
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at 
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at 
io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:274)
at 

Re: Error on line 25, column 9 in template/simple/radiomap.ftl

2017-11-08 Thread albert kao
Your suggestion is good!
My problem is solved.
However, the same error occurred when my jsp page is changed to the
following.
Please help. Thanks.


  


On Mon, Nov 6, 2017 at 9:04 AM, Yasser Zamani 
wrote:

>
>
> On 11/6/2017 4:37 PM, Yasser Zamani wrote:
> > then define myGoodList as List
>
> As you want to use inside an iterator, I think you want myGoodList as
> List.
>


When should SessionMap be used instead of Map?

2017-12-07 Thread albert kao
I am looking for an example that SessionMap should be used instead of Map.

In the Struts 2 Getting Started HTTP Session tutorial (
https://struts.apache.org/getting-started/http-session.html),
HelloWorldAction.java used
private Map userSession;

I used SessionMap to replace Map.
i.e.
private SessionMap userSession;

I got the same result after I compiled & executed the modified program, so
this is not an example to show the difference between SessionMap and Map.


Re: Recent examples

2017-12-25 Thread albert kao
The Showcase App
https://github.com/apache/struts/tree/master/apps/showcase
do not allow "Clone or download".

How to  "Clone or download" it?

P.S. https://github.com/lukaszlenart/struts2-tiles-demo allow "Clone or
download".

On Thu, Dec 21, 2017 at 8:55 AM, Lukasz Lenart <lukaszlen...@apache.org>
wrote:

> 2017-12-21 14:02 GMT+01:00 albert kao <albertk...@gmail.com>:
> > I had gone through the struts examples at
> > https://github.com/apache/struts-examples, which are very good.
> > Are there any recent (within this year if possible), more complex
> examples
> > or project good for learning (using best practices)?
> > I googled but some are old and some are not that good for learning.
>
> I don't know neither, there is also a Showcase App
> https://github.com/apache/struts/tree/master/apps/showcase
>
>
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
>
> -
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>
>


run the class ComponentTagExampleTest

2018-01-05 Thread albert kao
I downloaded a zip file of Showcase App from
https://github.com/apache/struts.
Then I unzipped it and run mvn.
I saw the class ComponentTagExampleTest.
How to run it?


Recent examples

2017-12-21 Thread albert kao
I had gone through the struts examples at
https://github.com/apache/struts-examples, which are very good.
Are there any recent (within this year if possible), more complex examples
or project good for learning (using best practices)?
I googled but some are old and some are not that good for learning.


Extra row appear in my jsp page after the Submit button is pressed

2018-03-11 Thread albert kao
I am debugging my test program.
When my test page http://localhost:8080/Struts2Example/updatePerson
appeared in the browser, it displayed
A
B
C
in its own textfield and a Submit button, which is expected.

However, after I edited the textfields and pressed the Submit button.
The following appeared in the browser.
Name :A
Name :Aa
Name :Bb
Name :Cc

I do not understand why an extra row (Name :A) appeared in the top with the
rest of the names which I just entered.

The following source codes is my test program.
updatePerson.jsp:
<%@page contentType="text/html" pageEncoding="UTF-8"%>
http://www.w3.org/TR/html4/loose.dtd;>
<%@taglib uri="/struts-tags" prefix="s" %>



Update Person


  
 
  
 
 
  


PersonAction


updatePersonResult.jsp:
<%@page contentType="text/html" pageEncoding="UTF-8"%>
http://www.w3.org/TR/html4/loose.dtd;>
<%@taglib uri="/struts-tags" prefix="s" %>



Update Person Result


 
Name :
 




Person.java:
public class Person {
private int id;
private String name;

public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}
}



PersonAction.java:
import java.util.ArrayList;
import java.util.List;

import com.opensymphony.xwork2.ActionSupport;

public class PersonAction extends ActionSupport {
private List persons;

public PersonAction () {
persons = new ArrayList();

int alpha = 65;
for (int i = 0; i < 3 ; i++) {
Person person = new Person();
person.setId(i);
person.setName(String.valueOf((char)alpha++));
persons.add(person);
}
}

public List getPersons() {
return persons;
}

public void setPersons(List persons) {
this.persons = persons;
}

//Initial Load method
@Override
public String execute() {
return SUCCESS;
}

//Function that handles the form submit
public String updatePerson() {

for(Person person : persons) {
System.out.println(person.getId() + ":" + person.getName());
}

return SUCCESS;
}
}




struts.xml:

  pages/updatePerson.jsp



  pages/updatePersonResult.jsp



Re: Extra row appear in my jsp page after the Submit button is pressed

2018-03-12 Thread albert kao
Problem is fixed.
Thanks!

On Mon, Mar 12, 2018 at 1:36 AM, Yasser Zamani <yasserzam...@apache.org>
wrote:

>
>
> On 3/12/2018 6:03 AM, albert kao wrote:
> >> name="persons[%{#stat.count}].name"/>
>
> I guess using #stat.index (instead of #stat.count) solves this issue.
> Count will be 1,2 and 3 but Index will be 0,1 and 2 which is same as
> that index that java uses.
>
> Regards.
>


Triple select tag

2018-04-14 Thread albert kao
I am looking for a triple select tag component which is similar to the
s:doubleselect tag (
https://struts.apache.org/tag-developers/doubleselect-tag.html).
It renders three HTML select elements with the third one changing displayed
values depending on selected entry of second one, and the second one
changing displayed values depending on selected entry of first one.
A generic triple select tag component is desired.
If not, a slim down version is welcome.
I googled and saw s:doubleselect tag examples but did not find anything
about triple select tag.
Please suggest any websites, blogs, examples or implementation tips.
Thanks.


Re: Triple select tag

2018-04-14 Thread albert kao
Martin,

My requirement is triple select tag component implemented with Struts 2
only, without any JS function.
I am still learning how s:doubleselect tag works.
I downloaded the source code from
https://www.mkyong.com/struts2/struts-2-sdoubleselect-example/, compiled
and run it successfully.
This is still work in progress, so I am still working on an example of 3
tag-components wired together.
Please suggest any websites, blogs, examples or implementation tips.
Thanks.


On Sat, Apr 14, 2018 at 2:25 PM, Martin Gainty <mgai...@hotmail.com> wrote:

> Hi Albert
>
> Thinking you could possibly hook JS function to doubleOnSelect of first
> component to highlight 3rd
> but
> would you have an example of 3 tag-components wired together?
>
>
> Martin
>
> __
>
>
>
> 
> From: albert kao <albertk...@gmail.com>
> Sent: Saturday, April 14, 2018 8:49 AM
> To: Struts Users Mailing List
> Subject: Triple select tag
>
> I am looking for a triple select tag component which is similar to the
> s:doubleselect tag (
> https://struts.apache.org/tag-developers/doubleselect-tag.html).
> Tag Developers Guide - Apache Struts 1<https://struts.apache.org/
> tag-developers/doubleselect-tag.html>
> struts.apache.org
> Edit on GitHub doubleselect. Please make sure you have read the Tag Syntax
> document and understand how tag attribute syntax works.
>
>
>
> It renders three HTML select elements with the third one changing displayed
> values depending on selected entry of second one, and the second one
> changing displayed values depending on selected entry of first one.
> A generic triple select tag component is desired.
> If not, a slim down version is welcome.
> I googled and saw s:doubleselect tag examples but did not find anything
> about triple select tag.
> Please suggest any websites, blogs, examples or implementation tips.
> Thanks.
>


Jsp fields are null at startup

2018-03-02 Thread albert kao
My jsp fields username and password are null at startup (jsp page is
loaded).
Why?
That make the "Invalid Username/Password. Please try again." message appear
when the page is loaded.
How to fix that?


Login.jsp
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>


Struts 2 - Login Application | ViralPatel.net



Struts 2 - Login Application











LoginAction.java
import com.opensymphony.xwork2.ActionSupport;
public class LoginAction extends ActionSupport {
private String username;
private String password;

public String authenticate() {
return execute();
}

public String execute() {
  if ((username != null) &&
(password != null) &&
this.username.equals("admin")
&& this.password.equals("admin123")) {
return "success";
} else {
addActionError(getText("error.login"));
return "error";
}
}

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;
}
}


Re: A book of Struts

2018-10-25 Thread albert kao
I think two books are in order:
First, S2 Basics / introduction : one single app development example.
Later, S2 Advanced: advanced topics, deep customization, Internals, Spring
integration, Javascript such as JQuery, etc.

I suggest
- moving Spring integration to the S2 Advanced book.
- adding IDE (Eclipse, ...) configuration to chapter 3.

Therefore https://github.com/lukaszlenart/struts-mini-book becomes:
1_introduction.txt
2_generate-project-with-maven.txt
3_basic-configuration.txt (with IDE (Eclipse, ...))
4_internal-di.txt
5_integration-with-tiles.txt
6_login-and-authenticate.txt
7_final-word.txt


On Thu, Oct 25, 2018 at 2:59 AM Lukasz Lenart 
wrote:

> pt., 19 paź 2018 o 14:06 Dave Newton  napisał(a):
> >
> > No recommendations; I'm forced to use Word right now for a Kindle book
> I'm
> > working on and I hate it (same when I did the S2 book) so don't do
> > that--makes code stuff needlessly complicated.
> >
> > There are many plain-ish-text systems out there--my personal preference
> > would be one of those, in a repo, and convert to final format. This also
> > allows you to write in code snippets you can pull from the same or
> > different repos, which is very convenient. I haven't found a great way to
> > do code fallouts though, like PragProg or Manning, in a trivial way.
>
> Thanks a lot Dave! Yeah, plain text is my favourite format :D
>
> I made a first step and the basic book setup is ready, you can preview
> it here [1] and the source code is available here [2]
>
> [1] https://leanpub.com/struts-mini-book
> [2] https://github.com/lukaszlenart/struts-mini-book
>
>
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
>
> -
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>
>


How to display both selected key and value of s:select

2018-12-22 Thread albert kao
I want to display both selected key and value of s:select.
e.g. for the following codes, after I select
key="2", value="Canada"
and press the submit button.
Only the key "Country: 2" is displayed in the registerResult.jsp as desired.
How to make the value "Canada" to display also in the browser?

public class RegisterAction extends ActionSupport {
private String country, selectedCountry;
private ArrayList countryList;

public RegisterAction() {
countryList = new ArrayList();
countryList.add(new Country(1, "India"));
countryList.add(new Country(2, "Canada"));
countryList.add(new Country(3, "US"));
return;
}
}

public class Country {
private int countryId;
private String countryName;
public Country(int countryId, String countryName)
{
this.countryId = countryId;
this.countryName = countryName;
}
public int getCountryId() {
return countryId;
}
public void setCountryId(int countryId) {
this.countryId = countryId;
}
public String getCountryName() {
return countryName;
}
public void setCountryName(String countryName) {
this.countryName = countryName;
}
}

register.jsp








registerResult.jsp
Country: 
selectedCountry: 
CountryListAll: 
CountryListAll2: 
CountryList: 
CountryList.get 


http://localhost:8080/Struts2Example/register.action
Country: 2
selectedCountry: CountryListAll: [com.test.common.Country@32cdbdf6,
com.test.common.Country@6cbe3d89, com.test.common.Country@7abf043f]
CountryListAll2: [com.test.common.Country@32cdbdf6,
com.test.common.Country@6cbe3d89, com.test.common.Country@7abf043f]
CountryList: com.test.common.Country@7abf043f
CountryList.get com.test.common.Country@7abf043f


Re: How to display both selected key and value of s:select

2018-12-27 Thread albert kao
Hi Yasser,

Thanks for your useful suggestion!
It works with:
public class RegisterAction {
...
   public Country getSelectedCountryObject(String selectedCountry) {
  for (Country c : countryList) {
 if (String.valueOf(c.getCountryId()).equals(selectedCountry))
return c;
  }
  return new Country(0, "");
   }
...
}



On Mon, Dec 24, 2018 at 3:00 AM Yasser Zamani 
wrote:

> Hi Albert,
>
> The simplest method can be something like this:
>
> public class RegisterAction {
> ...
> public Country getSelectedCountryObject() {
> foreach (c in countryList) if(c.countryId==selectedCountry) return c;
> }
> ...
> }
>
> 
>
> Thanks for using Struts.
>
> Kind Regards.
>
> >-Original Message-
> >From: albert kao 
> >Sent: Saturday, December 22, 2018 6:39 PM
> >To: Struts Users Mailing List 
> >Subject: How to display both selected key and value of s:select
> >
> >I want to display both selected key and value of s:select.
> >e.g. for the following codes, after I select key="2", value="Canada"
> >and press the submit button.
> >Only the key "Country: 2" is displayed in the registerResult.jsp as
> desired.
> >How to make the value "Canada" to display also in the browser?
> >
> >public class RegisterAction extends ActionSupport { private String
> country,
> >selectedCountry; private ArrayList countryList;
> >
> >public RegisterAction() {
> >countryList = new ArrayList();
> >countryList.add(new Country(1, "India")); countryList.add(new Country(2,
> >"Canada")); countryList.add(new Country(3, "US")); return; } }
> >
> >public class Country {
> >private int countryId;
> >private String countryName;
> >public Country(int countryId, String countryName) { this.countryId =
> countryId;
> >this.countryName = countryName; } public int getCountryId() { return
> countryId; }
> >public void setCountryId(int countryId) { this.countryId = countryId; }
> public String
> >getCountryName() { return countryName; } public void setCountryName(String
> >countryName) { this.countryName = countryName; } }
> >
> >register.jsp
> >
> >
> > >listValue="countryName"
> >value="selectedCountry"
> >headerKey="0" headerValue="Country"
> >label="Select a country" />
> >
> >
> >
> >
> >
> >registerResult.jsp
> >Country:  selectedCountry:
> > CountryListAll:  >value="getCountryList()" /> CountryListAll2:  >value="countryList" /> CountryList:  >value="getCountryList().get(country)" /> CountryList.get  >value="countryList.get(country)" />
> >
> >
> >http://localhost:8080/Struts2Example/register.action
> >Country: 2
> >selectedCountry: CountryListAll: [com.test.common.Country@32cdbdf6,
> >com.test.common.Country@6cbe3d89, com.test.common.Country@7abf043f]
> >CountryListAll2: [com.test.common.Country@32cdbdf6,
> >com.test.common.Country@6cbe3d89, com.test.common.Country@7abf043f]
> >CountryList: com.test.common.Country@7abf043f CountryList.get
> >com.test.common.Country@7abf043f
>


How to import Struts Examples into Eclipse IDE inside a single project

2019-02-09 Thread albert kao
How to import Struts Examples into Eclipse IDE inside a single project?

I tried this way but multiple projects (action-chaining, annotations, ...,
wildcard-regex) appeared in Eclipse Package Explorer.

I used "New Java project" to create the struts-examples-master project.
I downloaded and unzipped the struts-examples-master.zip from
https://github.com/apache/struts-examples.

I used "Import Maven", "Existing Maven Projects".

My struts-examples-master project src folder is still empty and multiple
projects (action-chaining, annotations, ..., wildcard-regex) appeared in
Eclipse Package Explorer
My Eclipse IDE for Enterprise Java Developers version is 2018-12 (4.10.0).


How to use s:iterator s:include s:param

2019-02-16 Thread albert kao
This display properly:

  

  


I refactor to the following two files, which display nothing.
I have other codes in items.jsp which confirms that items.jsp is being used
in showitems.jsp.
Please help.
Thanks.

items.jsp:



  

  




showitems.jsp:

  



s:property #attr working in header.jsp but not HTTP 404.jsp

2019-11-15 Thread albert kao
This line displays the proper value
   ">
in header.jsp:
   ">

but displays an empty string
in http404.jsp ("Page Not Found"):
   ">

Please help.
Thanks.


Re: s:property #attr working in header.jsp but not HTTP 404.jsp

2019-11-15 Thread albert kao
How to fix it?
I like to use a variable instead of hard coding like this:
">

On Fri, Nov 15, 2019 at 8:24 AM Lukasz Lenart 
wrote:

> pt., 15 lis 2019 o 14:13 albert kao  napisał(a):
> > but displays an empty string
> > in http404.jsp ("Page Not Found"):
> >">
>
> How do you access the http404.jsp? Directly, out of action? If so,
> there is no context that's why #attr doesn't work
>
>
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
>
> -
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>
>


How to pass parameters to s:component inside s:iterator?

2019-10-05 Thread albert kao
How to pass parameters to s:component inside s:iterator?
e.g. These simpilied codes pass the parameter "John" to items.jsp.
However, the browser displays an empty string.


  

  

  



items.jsp:

/>


How to auto submit a jsp page after loading

2019-10-03 Thread albert kao
How to auto submit a jsp page after loading is done?
i.e. after a jsp page is completely loading, it will auto submit - advance
to the next page without one of the Submit buttons is pressed or a link is
clicked.
This is desired for saving time when testing a web application.


How to set up the conditions to test web pages for HTTP status codes 403, 404, 500, 503

2021-06-17 Thread albert kao
I developed a web application with Java (Struts 2) and Web Experience
Toolkit (WET - https://github.com/wet-boew/wet-boew), which is running on
the WebLogic 12c server.
When any one of the HTTP status codes 403, 404, 500, 503 occurs, my web
application will display a corresponding web page.
e.g. When the HTTP status code 503 occurs, my web application will display
the web page 503.html.
How to set up or simulate the conditions to test my web application web
pages for HTTP status codes 403, 404, 500, 503?
i.e. simulate the HTTP status codes 503, etc so as to test my web
application UI to ensure that 503 is handled properly, assuming that the
webserver works properly.


Re: How to set up the conditions to test web pages for HTTP status codes 403, 404, 500, 503

2021-06-18 Thread albert kao
Following "Exception mapping" at:
https://struts.apache.org/getting-started/exception-handling.html

Something like:
public class HttpIOException extends Exception {
private static final long serialVersionUID = -4261703341L;

public HttpIOException() {
super("Http IO Exception");
}

public HttpIOException(String message) {
super(message);
}
}



public class Register extends ActionSupport {
//...
public void throwHttpIOException(String message) throws HttpIOException {
throw new HttpIOException(message);
}

public void throwHttpIO500Exception() throws HttpIOException {
throw new HttpIOException("HTTP response code: 500");
}

public void throwHttpIO503Exception() throws HttpIOException {
throw new HttpIOException("HTTP response code: 503");
}
//...
}



struts.xml

/500.jsp


/503.jsp


On Thu, Jun 17, 2021 at 9:08 AM Lukasz Lenart 
wrote:

> czw., 17 cze 2021 o 13:24 albert kao  napisał(a):
> >
> > I developed a web application with Java (Struts 2) and Web Experience
> > Toolkit (WET - https://github.com/wet-boew/wet-boew), which is running
> on
> > the WebLogic 12c server.
> > When any one of the HTTP status codes 403, 404, 500, 503 occurs, my web
> > application will display a corresponding web page.
> > e.g. When the HTTP status code 503 occurs, my web application will
> display
> > the web page 503.html.
> > How to set up or simulate the conditions to test my web application web
> > pages for HTTP status codes 403, 404, 500, 503?
> > i.e. simulate the HTTP status codes 503, etc so as to test my web
> > application UI to ensure that 503 is handled properly, assuming that the
> > webserver works properly.
>
> Exception mapping isn't enough?
> https://struts.apache.org/getting-started/exception-handling.html
>
> Or you can always re-implement ExceptionMappingInterceptor and used in
> your custom stack
>
> https://struts.apache.org/maven/struts2-core/apidocs/com/opensymphony/xwork2/interceptor/ExceptionMappingInterceptor.html
>
>
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
>
> -
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>
>


s:url s:a and s:text

2021-06-09 Thread albert kao
How to use s:url s:a and s:text together?
I tried this jsp but it did not work because some s:text did not get
substituted.


">



.properties file
comp.href=https://www.mycomp.com/client.html#x1
browser.window.title=Title
common.test.button=Test



I tried to modify this jsp but then it did not compile :(.
Please help.
Thanks.


How to pass value from AbstractInterceptor to ActionSupport classes

2022-02-02 Thread albert kao
My application likes to pass value from AbstractInterceptor to two
ActionSupport classes (codes below).
When the user presses the Back button of a browser, hasValue() return true
for class Action1.
When the user presses the Back button of a browser, hasValue() return null
for class Action2.
My log show that request.setAttribute(KEY, Boolean.TRUE); //line A are
executed for class Action1 and Action2.
Where is the bug?
Is it related to type="tiles" and type="redirectAction" in struts.xml?
Please help.
Thanks.



import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.struts2.StrutsStatics;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;


public class MyInterceptor extends AbstractInterceptor {
public static final String KEY = "KEY";

@Override
public String intercept(ActionInvocation invocation) throws Exception {
HttpServletRequest httpServletRequest = (HttpServletRequest)
ActionContext.getContext().get(org.apache.struts2.StrutsStatics.HTTP_REQUEST);

final ActionContext context = invocation.getInvocationContext();
session = context.getSession();
HttpServletRequest request = (HttpServletRequest)
context.get(StrutsStatics.HTTP_REQUEST);
HttpSession httpSession = request.getSession(true);

synchronized (httpSession) {
httpServletRequest.setAttribute(KEY, Boolean.TRUE); //line A
}
}
}


import org.apache.struts2.interceptor.ApplicationAware;
import org.apache.struts2.interceptor.RequestAware;
import org.apache.struts2.interceptor.SessionAware;
import org.apache.struts2.interceptor.ScopedModelDriven;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.Preparable;

public class CoreAction extends ActionSupport implements Preparable,
SessionAware, ApplicationAware, RequestAware {

public boolean hasValue()  {
HttpServletRequest httpServletRequest = (HttpServletRequest)
ActionContext.getContext().get(org.apache.struts2.StrutsStatics.HTTP_REQUEST);
return
Boolean.TRUE.equals(httpServletRequest.getAttribute(MyInterceptor.KEY);
}
}

public class Action1 extends CoreAction implements
ScopedModelDriven {
//...
}

public class Action2 extends CoreAction implements
ScopedModelDriven {
//...
}



Struts version is 2.5.26.


Virus-free.
www.avg.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>


Browser Back button intercept, no javascript

2022-01-25 Thread albert kao
If the user presses the Back button of a browser, my application likes to
intercept that and display a text message at the current web page.
How to do that without using javascript?

The following codes show an approach with AbstractInterceptor.
Please review whether it will work.
If yes, how to get the flag or value that the Back button of a browser was
pressed?
If not, please suggest alternatives.
Thanks.


import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.struts2.StrutsStatics;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;


public class MyInterceptor extends AbstractInterceptor {
private Map session;

@Override
public class MyInterceptor extends AbstractInterceptor {
private Map session;

@Override
public String intercept(ActionInvocation invocation) throws Exception {
   final ActionContext context = invocation.getInvocationContext();
   session = context.getSession();
   HttpServletRequest request = (HttpServletRequest);
  context.get(StrutsStatics.HTTP_REQUEST);
   HttpSession httpSession = request.getSession(true);

   synchronized (httpSession) {
   //...
   }
  }
}

Struts version is 2.5.26.


Virus-free.
www.avg.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>