provide-free-support Ujjwal's Blog: struts
Showing posts with label struts. Show all posts
Showing posts with label struts. Show all posts

Saturday, December 18, 2010

ForwardAction, IncludeAction and LocaleAction in struts


The org.apache.struts.actions.ForwardAction Class
The ForwardAction class provides a mechanism for forwarding 
to a specified URL. As explained earlier, in an MVC Web 
application, all requests to the application are supposed 
to flow through the Controller servlet. This ensures that 
the Controller layer of the application has an opportunity 
to prepare any resources that may be needed to handle the 
request (i.e., selecting the correct module and so on). 
ForwardAction is provided as a simple utility action that 
can be used for scenarios in which you simply want to link 
to a JSP page. Of course, linking directly to the JSP would 
be a violation of the MVC principles because all requests 
are supposed to be routed through the Controller. 
ForwardAction can be used to create links to JSPs so that 
you don’t have to create an action whose only 
responsibility is to forward a request every time you want 
to link to a JSP. With ForwardAction, you simply create an 
action mapping in the Struts configuration file and specify 
the location to which the action will forward.

To use ForwardAction, simply create action mapping entries 
in the Struts configuration file, as shown next:


  


Once configured in the Struts configuration file, 
LocaleAction can be put to use. Simply create a link to the 
action and specify the locale settings that will be set and 
a page to forward to. Locale settings are specified with 
two request parameters: language and country. The page to 
forward to after setting the locale is specified with the 
page request parameter. The following URL illustrates how 
to use the request parameters:

http://localhost:8080/MiniHR/SwitchLocale.do?
country=MX&language=es&page=/Menu.do 

This example URL sets the country to MX and the language to 
es. The /Menu.do page will be forwarded to after the new 
locale has been set.
Cheers,
Happy Coding :-)

Friday, December 18, 2009

Prevent Caching in Ajax

Hi,

6 months back, i was developing an application and i was facing an issue that even though i recreated new requests, the application fetched old data for me. However, later on i found that my application was using old data passed on as a URL parameter.

I resolved this in a simple manner.

My old URL was

                  url = "/getData.do"+ "?couCode=" + couCode;

I changed it to
                
                  url = "/getData.do"+ "?couCode=" + couCode+ "&ms=" + new Date().getTime();      

Thats what i did and the problem got vanished.....

Cheers!!!

Ujjjwal Soni

Monday, June 15, 2009

IE6 Ajax Problem with included .js file

Hi All,

Recently i got to make a site that was to be used globally in different browsers, i made this site using jsp and other bunch of technologies and frameworks. The site also has to be compactible to all known browsers world wide including blackberry and safari for iphone. On during the development stage i found a very strange problem in internet explorer 6, i included a javascript file for ajax and created some of its instances in calling page javascript code, the browser behaved very strangely,

It sometimes was able to create an instance of that ajax object and sometimes was not able to create an instance. Well, in ie7 the code worked like a butter. I finally concluded of not using that included javascript code and directly using that function code in the calling jsp page.

Check out the below scenerio:

*********My ajax.js file
/*
This function returns XmlHttpRequest Object for ajax support
*/
function getXmlHttpObject(){

//identify the browser
if (window.XMLHttpRequest) {
//alert(" you are using IE7 or mozilla");
try{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
if (xmlHttp.AJAX){
alert('firefox ajax support found');
}

}catch (e){
// Internet Explorer
var versions = ['Msxml2.XMLHTTP.7.0', 'Msxml2.XMLHTTP.6.0', 'Msxml2.XMLHTTP.5.0', 'Msxml2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP','Microsoft.XMLHTTP'];
for (var i = 0; i < versions.length ; i++){
try {
xmlHttp.AJAX = new ActiveXObject(versions[i]);
if (xmlHttp.AJAX){
alert('internet explorer ajax support found');
break;
}
}catch (objException) {}
}
}
return xmlHttp;

} else {
//alert(" you are using IE6");

try {
//alert("hello am in");
xmlHttp = new ActiveXObject('Microsoft.XMLHTTP');
//alert("hello am out");

if (xmlHttp == null){
alert('internet explorer ajax support not found');
}
}catch (objException) {}
return xmlHttp;
}
}



****************My.jsp (The calling page)



function checkAjaxInIe()
{
var xmlHttp = getXmlHttpObject();
if (xmlHttp == null)
{
alert("Your browser does not support AJAX!");
return;
}

}


After implementing this scenerio, try running this code on ie6 with script debugger activated, if you run this code 100 times, you will get probability of the calling page creating instance of included js file only 50 times from 100 times.

To resolve this, i simply included the included file's ajax function in all my jsps.

Cheers!!!

Ujjwal B Soni
best-it-exam-    | for-our-work-    | hottst-on-sale-    | it-sale-    | tast-dumps-us-    | test-king-number-    | pass-do-it-    | just-do-it-    | pass-with-us-    | passresults-everything-    | passtutor-our-dumps-    | realtests-us-exam-    | latest-update-source-for-    | cbtnuggets-sale-exam    | experts-revised-exam    | certguide-sale-exam    | test4-sale-exam    | get-well-prepared-    | certkiller-sale-exam    | buy-discount-dumps    | how-to-get-prepared-for-the    | in-an-easy-way    | brain-dumps-sale    | with-pass-exam-guarantee    | accurate-study-material    | at-first-try    | 100%-successful-rate    | get-certification-easily    | material-provider-exam    | real-exam-practice    | with-pass-score-guarantee    | certification-material-provider    | for-certification-professionals    | get-your-certification-successfully    | 100%-Pass-Rate    | in-pdf-file    | practice-exam-for    | it-study-guides    | study-material-sku    | study-guide-pdf    | prep-guide-demo    | certification-material-id    | actual-tests-demo    | brain-demos-test    | best-pdf-download    | our-certification-material    | best-practice-test    | leading-provider-on    | this-course-is-about    | the-most-reliable    | high-pass-rate-of    | high-pass-rate-demo    | recenty-updated-key    | only-for-students-free-download    | courseware-plus-kit-for    | accurate-answers-of    | the-most-reliable-id    | provide-training-for    | welcome-to-buy    | material-for-success-pass    | provide-free-support    | best-book-for-pass    | accuracy-of-the-answers    | pass-guarantee-id    | pass-exam-key    | pass-sku-id    | study-for-exid    | pdf-sku-exid    | sku-pdf-id    | pdf-demo-key    | exam-demo-ske    | pass-it-dump    |
http://www.menuiserie-dauvergne.com/    | http://www.menuiserie-dauvergne.com/    |