I'm having problems configuring struts 2 actions with dynacache. I'm following exactly what IBM says in 'Mastering DynaCache in WebSphere Commerce' about caching with struts.
I've created a sample application to practice/investigate dynacache and struts 2, everything (such as caching servlets and JSPs) is working fine apart from struts 2 actions. has anyone tried this before? has anyone made it working? please help me out and I would appreciate your help.
My sample application is working fine. I've got struts 2 installed and configured. All the actions are working fine. Since struts 2 does not work like struts 1.x ( I mean it does not need to have ActionServlet class any more) is there any difference between the way we cache struts 1.x actions and struts 2 actions?
o here is a copy of my cachespec.xml I have a few jsp pages which are being cached fine. and few actions that never get cached.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE cache SYSTEM "cachespec.dtd" >
<component id="header_id" type="parameter">
<component id="footer_id" type="parameter">
<component id="nav_id" type="parameter">
<component id="news_id" type="parameter">
<component id="featured_prod_id" type="parameter">
<!-- actions -->
<component id="*" type="parameter">
<component id="*" type="parameter">
<component id="prodId" type="parameter">
This topic has been locked.
4 replies Latest Post - 2013-02-11T16:34:54Z by QMF2_Jeff_Lynch
Pinned topic caching struts 2 action in dynacache... HOW?
Answered question This question has been answered.
Unanswered question This question has not been answered yet.
Updated on 2013-02-11T16:34:54Z at 2013-02-11T16:34:54Z by QMF2_Jeff_Lynch
Re: caching struts 2 action in dynacache... HOW?2008-12-08T07:01:25Z in response to SystemAdminHello! I'm a java developer who always try to use the best frameworks & technologies to deploy my projects. Sth like Struts, hibernate, Ajax, etc. Although I always search throw the new technologies & frameworks because likely some of them are better than the famous ones.
A few days ago, I was searching throw the http://www.eoslist.com that introduced the 84 best J2EE frameworks, tools & technologies. I found a new framework named Shine-app. Reading its description encouraged me to test it. Therefore, I downloaded it. It was interesting really!
Shine seems so nice but I can't trust on it yet because I don’t know it very much if you have any information about it please let me know about it more.
Re: caching struts 2 action in dynacache... HOW?2009-02-11T13:52:04Z in response to SystemAdminHi dear Dennis,
I found an essay about shine that want to share it with you! I really enjoyed myself! read and judge yourself!
I suggest you to use Shine instead of Struts! Its more powerful than it!
I put the figures in a word file!
J2EE and Service Oriented ProgrammingAuthored by: AmirSam Bahador
- The purpose of compilation this essay
Chapter 1: Basic concepts of J2EE
- Servlet and JSP
- MVC or JWMS? That is the problem? Perhaps both!
Chapter 2: Basic concepts of Shine Framework
- What is "Shine Framework”?
- The components of Shine Framework
- Implimentation of an application by Shine Framework
- The types of objects in Shine Framework
Chapter 4: Engineering & Communication items
- The communication of Shine Framework with the other
- existing Frameworks*
The purpose of compilation of the this paperA few years ago, when I was the software architect of a big project with J2EE, I advised some of the modern tools of that time to the project manager. He acknowledged it. Therefore, we began deploying our Enterprise on Java platform. However, we encounterd with many problems, as we got ahead the project. Our tools were included Struts Framework, Spring Framework & Hibernate.
I convinced that MVC architecture is the best option to develop macro projects! However, I believe it now, as well. Couldn't it be more completed? In developed Enterprise projects, an advanced architecture is required to divide the project, technically. The project was successfully finished after one year, but my mind was busy with it for a long time!
Then, I began implementing an Application Framework and registered it in Sourceforge.net as an Open Source Framework. I developed some Enterprise projects & some other J2EE frameworks, as well. I achieved a good result! The velocity of implemention & developing projects increased up to 50%. Subsequently, by cooperation of my elected students who had worked with Application Framework, I established an organization, named J2SOS, to protect & develop this Application Framework.
Fortunately, my students were so skilled that each took a chief task in big J2EE projects.
Their experiences had a practical affect on development of Application Framework as well as the organization.
Therefore, it is required to write down my & my yesterday students (my today co-workers) experiences. This was the outset to write the present paper!
The basic concepts of J2EE
PurposesIn this chapter, we do our best to introduce J2EE basic concepts.
Servlet & JSPIf you ahve ever worked with JSP & Servlet, you know that Servlet is so proper for processing functions but there are particular problems with it in displaying functions.
JSP is applied reverse to Servlet. Thus, what is the solution? To apply both JSP and Servlet together!
What is MVC?MVC is an easy way to use JSP & Servlet together. In MVC architecture, the request will be processed by a Class (Servlet) and the appropriate response will be showen by JSP.
See Figure 1-1
In the above Servlet Class, the validation operation, etc will be done.
Nowadays, there are numerous Frameworks which will assist you to use MVC Framework architecture. Struts Framework is the most well-known one.
MVC or JWMS ? That is the problem! Perhaps both!
MVC is a powerful architecture, but it is required an advanced architecture to implement developed projects.
Today, web applications are well developed which complicatethe work for programmers & developers.
To clarify it, see Google site! Google Web Application enjoys numerous services, each have a special service for the users.
For Instance, Gmail service, E-Mail or by SearchEngine, the users can search for websites, pictures, etc.
These services have certaily close communication with each other.
If the services do not use a particular architecture, the Google will encounter with various problems.
In Service Oriented architecture, each part of the program is a service programme. For example, E-Mail service, SearchEngine service, etc.
Consider Electeronic-Goverment application. This application does numerous services; each can be regarded as a separate application.
However, there is a problem! These applications should have communication with each other, i.e., a communication which is not a simple messaging one! I propose JWMS architecture to solve this problem!
Java Web Model Service (JWMS) transforms each part of E-Government application to a service. For instance, E-Bank service, E-Ministry service, etc.
See Figure 1-3
As you see, the request of user is transfered to Model via Web, it is processed by the Model t and the user is directed to the proper Service.
Model means a Servlet which processes the Request of the user.
It is likely that, in the first outlook, this architecture looks like MVC. Wait! You are not familiar with its internal components, yet!
To understand it obviously, you should be familiar with a Framework.
J2EE Service Oriented Programming In SHINE Framework
Basic concepts of Shine Application Framework
The purpose of this chapter is to introduce you Shine Application Framework.
What is Shine Application Framework?
Shine Application Framework is a Service Oriented Framework which assists you to implement applications in accordance with MVC & JWMS architedtures.
The components of Shine FrameworkIn applications which impliment by Shine, the request is first processed by the Model and the user is directed to the proper Service.
The Class that acts as Model is called Mapping. Mapping Class is similar to a servlet.
Each Mapping Class should extend “j2sos.shine.controller.Mapping” Class & implement “public void rater()” method.
Each service includes a JSP or a JSF page or … in which there are a succession of Shine’s rules and its exclusive tags.
See Figure 2-1:
Let’s review exclusively the components of the application which have been implemented by Shine.
See Figure 2-2:
The request is processed when it inserts the Mapping Class which spacifies the appropriate service for the user’s request and directs the user toward the service by web.xml file.
Implementation of an application by Shine Framework
Make a web application as below:
Then apply “shine.jar” file to your library.
After adding the mentioned library, change “web.xml” file as follow:
Now, let’s analyze this file.
- “Description” tag indicates the name of application.
- “Servlet-name” & “servlet-class” tags show the name & address of “Mapping” class.
- “Init-param” tag and “ServerConsoleStatus” property & its “true” value notify Shine that the descriptions of the request should be displayed in Server side
This property will help you to get information about the requests via text environment of ApplicationServer. This property will certainly remind you of “showsql” in “Hibernate”.
- “Init-param” tag & its “Content-Type” property indicate the type of the contents of the response.
- "Init-param" tag & "servicename1", "servicename2" properties identify two services to Shine as well as specify the address of each service on the same server or the other one in Shine.
- "Servlet-mapping" tag indicates a name to attain "Mapping" class to the requests.
- The address of the library of Shine is identified to the ApplicationServer by "Taglib" tag.
Getting to know setting of Shine's properties in "web.xml" file, you should put "shine.tld" file beside "web.xml" file.
At present, “ properties’ setting of “web.xml” file is finished & we should consider the “Mapping” classes.
All of “Mapping” classes should be extended “j2sos.shine.controller.Mapping” class and implement “public void rater()” method.
For instance, let’s impliment “view.MyMapping” class.
As you see, this class enjoyes a method named “rater”. When the request inserts the “MyMapping” class, It will automatically be called.
This method is responsible for the first processes on the requests.
It is obvious that another method has been called in this method.
“Forward” method lead the user to the proper service. In this example, the user will be directed to “servicename2” service.
The value of “tag1” will be further explained next.
It is noted that you can call “forward” method by the other methods.
As it is previously mentioned, “servicename1” & “servicename2” indicate the address of two JSP pages which perform as a service.
Let’s implement one of these services (JSP pages).
Since “servicename2” is utilized in the previous example, we implement “service2.jsp” now. First “web.xml’ should be reviewed.
Iimplement a JSP page initially named “service2” with the following contents:
In the beginning of the above page, the library of ApplicationServer is identified.
This page (Service) includes four principal tags.
“header” & “footer” tags act as the same as header & footer of text pages.
The values of “tag1” & “tag2” perform as two pages. When you call “forward” method in “MyMapping” class as below:
The user will be directed to “service2.jsp” as well as “tag1” will be displayed alongwith header & footer.
This is Shine Application !
Hello , this is service 2 and tag 1
Now, if you call “forward” method in “MyMapping” class as below:
The user will be directed to “service2.jsp” and “tag2” will be displayed alongwith header & footer.
This is Shine Application !
Hello , this is service 2 and tag 2
This type of coding in these pages lead to data sorting. In these pages, you can get values once via JSP and use it in all tags.
In fact, in this architecture, JSP pages act as “Service” & tags are considered as your “pages”.
Now, let’s impliment “service1.jsp” page.
To direct user to this service, it is merely required to call “forward” method as below:
To get the address of JSP pages & setting them in “web.xml” file, each page is directly run directly, then its address is indicated in “web.xml” file.
In these pages, reverse to Struts, you can use objects of request, response, etc in JSP since URL values are sent to JSP pages (Services) by “Mapping” classes send to.
Being acquainted with “Mapping” classes & “Service” pages, you should be able to send the request of user to “Mapping” class.
Therefore, It is required to set the value of the Action of HTML forms on your Mapping classes.
It is observed that this form bears a text field called “name” and the value of its action has been set on “MyMapping” class.
Now, let’s survey on sending request by Ajax! In this example, you should put “ajax.js” & “md5.js” files beside the request page.
As you can see, this form have a name. its information is sent to “MyMapping” class via “ajaxSubmit” method.
The value of “flase” in “ajaxSubmit” method causes the user not to communication with the request page till receiving the response.
“AjaxLoad” method will automatically be called when the form is sent. While the response is received, “ajaxResponse” method will be called, as well.
The value of “content” value includes the response of “MyMapping” class.
You can use “ajaxMD5Submit” method instead of “ajaxSubmit” one to send the information of form in MD5 format to “MyMapping” class.
“ajaxEternalSend” method acts similar “ajaxSubmit” method but it sends an URL and receives response, constantly. For instance:
In this method, the number “4” indicates a time scale to send URL to the “MyMapping.exec” class again.
Some other methods are determined in “component.js” file to help you in communication with java.
The objects of Shine Framework
In this chapter, the objects of Shine framework will be discussed.
The types of objects of Shine frameworkAs you know we have not achieved a parameter in mapping classes yet, therefore, 3 methods are used in these classes as follows;
- getRequest() method acts similar to request object in JSP.
getConfig() and getResponse() method are applied the same as getRequest() too.
j2sos.shine.script.Server class help you work with server operating system API. If you intend to install a web based operating system, you can use this class.
The followings are the methods of this class:
To work with each method, you should make an object from this class.
Herein, the above methods are described.
Write() and writln() methods create a text on textual consul of Application Server.
getFileValue() method receives a directory and afile name, then return the contents of textual file.
writeFile() method receives a directory, a file name as well as file contents and makes a file in server.
createFolder() method recieves a directory and a file name to create a folder in server.
deleteFolderAndFile() method deletes a file or folder in server.
getCurrentDate() method sends back server's local time .
shutDownApplication() method stops the executing application.
j2sos.shine.script.CompietionRequest class helps you to receive parameters from URL. The followings are the methods of this class:
getUserid() method sends back identify number of the user session.
getRequestCounter() method makes a general counter and recieves a value for indicating the step of counter.
The other methods of this class perform similar to request.getParameter("ParamName") command, except they help you in casting and validation.
For instance, getStrParam("name","it is null") method leads the value of name to be sent back from URL, if this value is not available in URL, "it is null" value is returned.
j2sos.shine.monitor.ServerConsole class bears a method named showSeverConsole, which receives an object of request and displays the descriptions of request by application server console.
j2sos.shine.socket.ResponseService class have a method named getTagText, which receives an URL and tag name, then returns the contents of tag.
Engineering and communication items
In this chapter, you are acquainted with engineering and communication items.
The communication of Shine Framework with other existing Frameworks
As you now, the communication of a framework with other frameworks is extremely important.
You can communicate with other frameworks in shine.
These frameworks include as follows:
Or even Jsf, I am sure you have idea in this regard.
I try my best to put some of frameworks beside shine.
You can have several methods in mapping classes, for instance:
In this class, it is first received PageName value from URL.
Next, regarding PageName value, the service which should respond the request, will be identified.
If the insert value is p, p1Validation() method will be called.
If the input value is p2, p2Validation() method will be called.
If it is not input any P1 & P2 values, the user will be directed to errorservice and the value of notexisturl tag will be displayed.
If it is not input any P1 & P2 values, the user will be directed to errorservice and the contents of URL tag will be displayed.
If the developer makes an Exception, the user will be directed to errorservice and the contents of exp will be displayed.
Suppose we made an aspect file and programming it as before running each of methods(P1Validation, P2Validation), the other method is called.
Therefore, you will create a powerful management in mapping2 class.
Now, let's combine struts and shine together. It is required to use struts tags in your own service tags. For instance:
As you see, you can easily communicate with other existing frameworks in shine.
There have been published numerous papers about SHINE and JDBC , etc. See the following website:
The major purpose of Shine framework
The main purpose of shine framework is implementing service oriented applications. In this framework, the developer is focused on implementing services.
This framework includes java web model service (JWMS) and MVC , which provides a particular system in implementing enormous applications.
J2SOS Organization Web Site: http://www.J2SOS.org
Shine J2EE Framework 1.2 Vs. J2EE Frameworks2009-02-16T20:45:46Z in response to SystemAdminShine J2EE Framework 1.2 Vs. J2EE Frameworks(picture less)
Author: Amir Sam Bahador
-The object of edition of this article
First chapter: Can one method change all things?
-One new method
The object of editing this essay:
What we expect from the new tools, are not more than what they are, so we can hope. For few years, new J2EE Framework for Java did not become popular like the Struts. I do not say that it is not made, but I say that it did not become popular, but we submitted you new program more that what you expect, so be ready and choose your way and method.
A way for approaching shine.
First chapter: Can one method change all things?
In this chapter, we are going to acquaint you with shine's new features in 1.2 editions.
One new method:
In the previous small article (J2EE And Service Oriented Programming), you have acquainted with shine. If you have not studied the article J2EE And Service Oriented Programming, firstly, I suggest you to study it, then keep continuing to study this article, because I do not like to make voluminous article, whereas others like it.
I am sure that you have worked with Session, Application in JSP and FormBean in Struts. Utilizing each of them has the own special problems. Disadvantages of utilizing the above mentioned cases are traffic bar in Ram level, complicated codes and boring.
As we addressed in the previous article, on the contrary to Struts, in Shine, you can use the URL parameters in the services.
For example, you can send the name's contents to the mapping class via one URL, and after the processing the name's contents, guide the user toward a service, you can use the URL's contents again in the considered service. This process was not possible in Struts, and not now, you have 3 principal options for doing this process in Struts.
1- Utilizing the Session: making busy the server RAM.
2- Utilizing the Application: limited utilizing
3- Utilizing the FormBean: establishing some extra classes
It is done easily in shine; you can use easily URL's contents in considered service again in shine. But, it is not finished yet.
For clearing the case, we give an example. You have made a HTML form in which there is a context filed which is titled famil. When the user submits the form, the functional program will guide him/her toward the mapping class. In the mapping class, the amount of received URL which contains the famil has been considered, and user is guided toward the special service.
In the considered service, the famil amount has been received and displayed twice; this is what the shine does!
There is a small problem, assume that you need to produce amount and send it to the considered service in the mapping class. this amount does not exist in the HTML format! Mapping class undertakes to produce this amount.
In the mapping class, you can not use Application, Session and FormBean.
As you see, the above mentioned function is not possible in shine, but be careful that there is a much loveable creature which is titled URL.
In the mapping class, you are able to add an amount to the URL easily and guide toward the considered service.
I give an example regarding the above mentioned case, in order to clarify the matter:
You have created an HTML format, in which there is a context field which is titled famil, when the user submits the form, the functional program guides him/her toward the mapping class, in the mapping class, the received URL's amount which contains the famil's amount is considered and the age will be created, and after doing this process, the age will be added to URL, and the user is guided toward a special service. In the considered service, the famil amount and age are obtained from URL and displayed for it.
Come to observe the amounts of URL's parameters before entering the mapping class:
Now, come to observe the amounts of URL's parameters after exiting the mapping class, and before entering the service:
Be careful that there is no limitation in utilizing the method of addURL , you could use session just one time, but you can use this method , pay attention to the following example:
In the previous example, the famil's amount was sent through form and URL to the mapping class, when the code is done, age=23 and name =Amir is added to URL, now you can receive amount, name, age and famil in the considered service 2 and show it to the user.
With the above mentioned method, you have used URL instead of application, now come to use URL instead of session.
In the above code, the age and name will be added to URL in any condition.
If the user famil will be equal to fowler, the amount of sent URL to service 2 will be as follow:
If the user famil will not be equal to fowler, and for example, it would be equal to bahador, the amount of sent URL to service1 will be as follow:
Now, pay attention to the following code:
If the user famil will be equal to fowler, the amount of sent URL to service 1 will be as follow:
With utilizing this method, you do not need Session, Application and FormBean.
J2SOS Organization Web Site: http://www.J2SOS.org
to read the article with the pictures see the attached file!