Developer's experience

October 6, 2011

how to make RestEasy close http connection after each request

Filed under: Uncategorized — migut @ 10:25

RESTful framework http://www.jboss.org/resteasy/

HTTP client apache http client http://hc.apache.org

SimpleHttpConnectionManager httpConnectionManager = new SimpleHttpConnectionManager(true);
HttpClientParams params=new HttpClientParams();
HttpClient httpClient=new HttpClient(params,httpConnectionManager);
ApacheHttpClientExecutor exec=new ApacheHttpClientExecutor(httpClient);
return ProxyFactory.create(MyService.class, url,exec);

September 18, 2009

Apache Struts wrong locale problem

Filed under: Uncategorized — migut @ 23:39

[#LDEV-1140] Welsh translation issues – LAMS

When getting a message resource in struts, we need to explicitly set the locale, otherwise it will just use the default locale (US English). The struts implementation of getResource() DOESN’T pick up the struts preferred locale setting .

this is TRUE!

July 20, 2009

Using Locale in Struts1/JSTL application

Filed under: Uncategorized — migut @ 11:10

When u are creating multi-language Struts and JSTL web application, then it is important to change also locale for FMT config… then u can use fmt:message tag to display property:
<fmt:message key=”app.link.locale.text”/>

sample action class below. Enjoy!

import java.util.Locale;

import com.plansolutions.web.action.BaseActionWithSpringIntegration;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.jstl.core.Config;

public class LocaleAction extends BaseActionWithSpringIntegration {
   
    private static String LOCALE_PARAM=”locale”;
    
    public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
        if (log.isDebugEnabled()) {
            log.debug(“Entering ‘LocaleAction’ method…”);
        }        
        if (request.getParameter(LOCALE_PARAM)!=null) {            
            if (request.getParameter(LOCALE_PARAM).indexOf(“en”)>=0)
                setLocale(request, Locale.ENGLISH);
            else
                setLocale(request, Locale.GERMAN);
        }
        if (log.isDebugEnabled())
            log.debug(“setLocale after=”+request.getSession().getAttribute(“org.apache.struts.action.LOCALE”));
        return mapping.findForward(“referer”);
    }
    
    @Override
    protected void setLocale(HttpServletRequest request, Locale locale) {        
        super.setLocale(request, locale);
        Config.set(request.getSession(), Config.FMT_LOCALE, locale);
        if (log.isDebugEnabled())
            log.debug(“setLocale=”+locale);
    }
}

March 29, 2009

Hello world!

Filed under: Uncategorized — migut @ 11:36

Let’s start!

it wil be about java and.. java! i hope sth more, that just yet another dev blog!

java!

The Shocking Blue Green Theme Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.