Locale-specific JSP page

Hi,
I want to provide internationalization in my web tier by providing locale-specific JSP pages rather than using resource bundles for the content inside the JSP page.
In other words, I'd like to have a folder structure such that I have a default .jsp file in the root folder and locale-specific .jsp files under the locale folders as following:
  /jsp
      /index.jsp
      /en_US/
             index.jsp
      /en_GB/
             index.jspAnd depending on the default locale of the server (not user's). I'd like the appropriate index.jsp to be picked up at runtime.
If the above is not possible, I even wouldn't mind using a locale suffix for the JSP files:
  /jsp
      /index.jsp
      /index_en_US.jsp
      /index_en_GB.jspIs there any way to do this?
Thanks, Rishabh

Well yeah, I did want the server to pick up the "best fit" JSP page automatically, going from specific to general. So if /en_US/index.jsp is missing, it should default to /index.jspSomewhat like how ResourceBundle handles property files.
This approach is suggested in the Designing Enterprise Applications with the J2EE Platform book in the J2EE Internalization and Localization (http://java.sun.com/blueprints/guidelines/designing_enterprise_applications_2e/i18n/i18n4.html) section 10.3.3.5 - Locale-Specific JSP Pages. Of course here they use the users's locale from the request to do this. But using the default locale of the server should pretty much be the same thing.
If the above doesn't really work, can anyone suggest how I can hook into the request handler or write a custom servlet filter as suggested by Ram to do this at a framework level so that it works for all my pages?
Thanks, Rishabh

Similar Messages

  • No Button in a specific JSP page fires event..

    hi
    I desperately need help in following thing.
    I wanted to sort a datatable by command links in headers but those were not firing events so i used teh buttons instead. They kept on working fine but now something weird has happened. Neither the buttons in the header nor anywhere else on page work .. (I copy - pasted the sorting logic into a button outside datatable) but this button is also not working. If i use the debugger then debugger doesnot go into any of the actionListener methods. My CreatorLog file shows the following trace.
    INFORMATIONAL *********** Exception occurred ************ at Fri Jul 15 06:42:44 java.lang.InstantiationException
    at sun.reflect.InstantiationExceptionConstructorAccessorImpl.newInstance(InstantiationExceptionConstructorAccessorImpl.java:30)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
    at java.lang.Class.newInstance0(Class.java:308)
    at java.lang.Class.newInstance(Class.java:261)
    [catch] at com.sun.rave.insync.beans.BeansUnit.instantiateBean(BeansUnit.java:1101)
    at com.sun.rave.insync.live.LiveUnit.ressurectDesignBean(LiveUnit.java:316)
    at com.sun.rave.insync.live.LiveUnit.resurrect(LiveUnit.java:379)
    at com.sun.rave.insync.live.LiveUnit.sync(LiveUnit.java:276)
    at com.sun.rave.insync.models.FacesModel.sync(FacesModel.java:761)
    at com.sun.rave.designer.DesignerTopComp.sync(DesignerTopComp.java:657)
    at com.sun.rave.designer.DesignerTopComp.componentShowing(DesignerTopComp.java:761)
    at org.openide.windows.WindowManager.componentShowing(WindowManager.java:333)
    at com.sun.rave.windowmgr.WindowManagerImpl.componentShowing(WindowManagerImpl.java:375)
    at com.sun.rave.windowmgr.LayoutManagerListenerImpl.layoutWindowShown(LayoutManagerListenerImpl.java:69)
    at com.sun.winsys.layout.impl.RLayoutManager.fireWindowShown(RLayoutManager.java:289)
    at com.sun.winsys.layout.impl.RLayoutWindow.fireShown(RLayoutWindow.java:482)
    at com.sun.winsys.layout.impl.RTabbedDocumentPane.fireChangedNoActivate(RTabbedDocumentPane.java:400)
    at com.sun.winsys.layout.impl.RTabbedDocumentPane.stateChanged(RTabbedDocumentPane.java:388)
    at javax.swing.JTabbedPane.fireStateChanged(JTabbedPane.java:287)
    at javax.swing.JTabbedPane$ModelListener.stateChanged(JTabbedPane.java:219)
    at javax.swing.DefaultSingleSelectionModel.fireStateChanged(DefaultSingleSelectionModel.java:116)
    at javax.swing.DefaultSingleSelectionModel.setSelectedIndex(DefaultSingleSelectionModel.java:50)
    at javax.swing.JTabbedPane.setSelectedIndexImpl(JTabbedPane.java:468)
    at javax.swing.JTabbedPane.setSelectedIndex(JTabbedPane.java:461)
    at com.sun.winsys.swing.BasicClosableTabbedPaneUI$MouseHandler.mousePressed(BasicClosableTabbedPaneUI.java:3456)
    at java.awt.Component.processMouseEvent(Component.java:5097)
    at java.awt.Component.processEvent(Component.java:4897)
    at java.awt.Container.processEvent(Container.java:1569)
    at java.awt.Component.dispatchEventImpl(Component.java:3615)
    at java.awt.Container.dispatchEventImpl(Container.java:1627)
    at java.awt.Component.dispatchEvent(Component.java:3477)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3195)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128)
    at java.awt.Container.dispatchEventImpl(Container.java:1613)
    at java.awt.Window.dispatchEventImpl(Window.java:1606)
    at java.awt.Component.dispatchEvent(Component.java:3477)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
    Jul 15, 2005 6:42:46 AM com.sun.faces.renderkit.html_basic.HtmlBasicRenderer getForComponent
    WARNING: Unable to find component with ID 'componentLabel3' in view.
    If i open the server log from server navigation it doesnot show any other message on button clicks...
    plz help..

    hi
    thanks for reply.. But what if i want to do my own sorting. I am making enterprise application using JSF (Sun Creator). Using my own layered architecture.
    The prolem is why Creator(/JSF??) behaved so unpredictably. One moment all the buttons in header of datatable were working fine and other moment an exception trace was found in Creator Log(Help->CreatorLog)??
    What went wrong..
    Any possible reasons??

  • How to open a local file from javascript in a jsp-page

    Hi
    I have created an iview from a PAR file. In the par file I have a jsp-page with some javascript code. From the javascript coe I want to open a new window with an Excel file.
    I have tried window.open("c:
    test.xls", "test_window"), but it doesn't seem to work. I have created a small HTML page locally with the same command and there a new window opens with the Excel file.
    If I change the local file path with an URL it also works.
    Any idea how to open a local file ?
    Thanks
    /Jakob

    Jacob,
    I'm not 100% (but 99,9%) and it has to do with security ristrictions of the browser not allowing to have local workstation interation from the web. This is ofcourse very dangerous if the browser would allow it... So therfore it is blocked. What if somone would point to a file/executable that formats your drive so for that reason it is not allowed to have web interaction with a local file. Only with Java Applets this is possible but still with many limitations, and what I remember Google Gears and Adobe Air do have some limited web 2 local file interaction... So best and most simple solution you are left with is pointing to a url instead of a file on a c:\ drive.
    PS The reason why it works when you start the html from your local PC has todo with the fact that the browser detects that the html is not running in the web at that moment therefor allowing the access.
    Cheers,
    Benjamin Houttuin

  • Linking to a specific frame from JSP page

    I am trying to link to site that has frames. I want to load a specific jsp in frame 3. Does anyone know how to pass the target and source values? I have been looking for tutorials unsuccessfully.

    You can not point to a specific frame ina document from an external document.Your best bet might be to pass the parameters using URL and on the recieving end write some javascript to parse the url adn if it has a parameter then process that else just load standard document.
    Khalid

  • Dynamic table on specific height of JSP page

    I have large data.
    I have to show this data in dynamic table on jsp page.
    the JSP page is logically divided in different pages (as this page is used for printing on specified size of page)
    I can only display atmost 12 single rows on one page
    but some times text of one column of row become so large that rows expands vertically and occupies space of 2 or 3 rows (thats why now i have to display 8 or 9 rows on first page and then remaining on next )
    becoz of this i cant implement this check (only show 12 rows on a page).
    so what can i do to show specified height of table on one page and remaining move to next page.

    This is an impossible requirement. Page, font and element height is not only browser dependend, but also depending on the settings of the user. Some users will override the font size to be smaller or bigger using a browser option, resizing your table accordingly. Mac fonts might have different sizes if the fonts are antialiased, etc.
    You'd have more success if you could output the table as PDF, there are far more table spacing options available, it's portable and you have 100% control over the output. Check out the iText API for example. The only problem with this is that the PDF will be opened by a PDF viewer which you cannot control, so you cannot make it automatically print.

  • Help Required  !!! -- Dynamic table on specific height of JSP page

    I have large data.
    I have to show this data in dynamic table on jsp page.
    the JSP page is logically divided in different pages (as this page is used for printing on specified size of page)
    I can only display atmost 12 single rows on one page
    but some times text of one column of row become so large that rows expands vertically and occupies space of 2 or 3 rows (thats why now i have to display 8 or 9 rows on first page and then remaining on next )
    becoz of this i cant implement this check (only show 12 rows on a page).
    so what can i do to show specified height of table on one page and remaining move to next page.

    This is an impossible requirement. Page, font and element height is not only browser dependend, but also depending on the settings of the user. Some users will override the font size to be smaller or bigger using a browser option, resizing your table accordingly. Mac fonts might have different sizes if the fonts are antialiased, etc.
    You'd have more success if you could output the table as PDF, there are far more table spacing options available, it's portable and you have 100% control over the output. Check out the iText API for example. The only problem with this is that the PDF will be opened by a PDF viewer which you cannot control, so you cannot make it automatically print.

  • Have to display a dynamic table on specific height of JSP page

    I have large data.
    I have to show this data in dynamic table on jsp page.
    the JSP page is logically divided in different pages (as this page is used for printing on specified size of page)
    I can only display atmost 12 single rows on one page
    but some times text of one column of row become so large that rows expands vertically and occupies space of 2 or 3 rows (thats why now i have to display 8 or 9 rows on first page and then remaining on next )
    becoz of this i cant implement this check (only show 12 rows on a page).
    so what can i do to show specified height of table on one page and remaining move to next page.

    hi,
    its not so easy ...i had this problem once befor 2 months in the work
    i think u have to implement a Controller.java class that controll the iterating between pages ...
    u should have an pageIndex and just play with this index (increment and decrement)

  • JSP pages not working on app server but works locally

    Hello,
    My application uses java, struts and jsps. When I try to access JSP page like http://appServer:7778/app/login.jsp, it says page not found exception. But when I access http://appServer:7778/app/login.do, it displays login.jsp page (success url for login action is login.jsp). How come I am not able to access jsp pages directly? Am I missing any settings?
    And when I run the application using embedded OC4J of Jdeveloper, I could access jsp pages directly.
    Thanks.

    The method getTextContent() is DOM Level 3, and was introduced with Java1.5
    Tomcat 5.5 runs on Java1.5, but by default uses the JDT compiler for JSPs, which is only Java1.4 compliant - might possibly be that.
    See the [url http://tomcat.apache.org/tomcat-5.5-doc/RELEASE-NOTES.txt] release notes and
    [url http://tomcat.apache.org/tomcat-5.5-doc/jasper-howto.html]how to fix (see the section on configuration)
    >
    The Java compiler from Eclipse JDT in included as the default compiler. It is an advanced Java compiler which will load all dependencies from the Tomcat class loader, which will help tremendously when compiling on large installations with tens of JARs. On fast servers, this will allow sub-second recompilation cycles for even large JSP pages. This new compiler will be updated to support the Java 5 syntax as soon as possible.
    Apache Ant, which was used in previous Tomcat releases, can be used instead instead of the new compiler by simply removing the common/lib/jasper-compiler-jdt.jar file, and placing the ant.jar file from the latest Ant distribution in the common/lib folder. If you do this, you also need to use the "javac" argument to catalina.sh.

  • How can you opening the tree.jsp page to a specific folder?

    I am trying to pass a query string into the viewer.jsp page so that I can open the appropriate folder relating to that query string. I can't find a way to do this as of yet. A lot of the code doing the work is only .class files so it is challenging.
    If you have any ideas as to how to begin to tackle this problem please let me know. Basically the querystring would contain the folder I want the tree to open to.
    Thanks,
    Simon

    See:
    *https://mike.kaply.com/2012/02/09/integrating-add-ons-into-firefox/

  • Using a Statefull Session Bean with RMI on Multiple JSP pages

    Heya all,
    i have a JBoss server running with a statefull bean on it. I want to use it on my JSP pages. But every time I start my JSP-page a NEW INSTANTION of the bean is created! For each user using my page, I want ONE bean.
    Is there anyway to do this? ANything with the sessioncontext?
    I can do it with local beans, using the simple tags in the JSP-page, but they do not work for Remote Beans.
    (I use JNDI)

    hi,
    statefull session beans are client session specific. the instance will exists if client session exits.
    now since u are loading the jsp page again in the other browser, a new instance will be associated with the current session.
    hope it will work.
    sameer

  • Why some coms not able to load certain JSP pages?

    Hi according to above,
    was thinking of creating jsp pages, but there seems to be occasional problems of not able to view jsp pages even though the computer has the updated JRE and has also try other browsers and had also reinstall JRE for a few times.
    Anyone know how to resolve this issue? The only method is I know is to format the computer and reinstall windows. Is this a windows issue or a jsp issue?

    i think you're confused. Applets need to have a local JRE on the client, JSP and servlets do not. All the java action in a JSP is performed on the SERVER, not the CLIENT. The server merely spits back to the client HTML (and possibly javascript) code just like any other static HTML page.
    Therefore, no web browser have ever not been able to view a JSP page. There may have been JSP pages that used JavaScript that doesn't work in all browsers, or JSP pages that returned invalid or browser specific HTML pages. But that's not JSPs fault.
    JSP --> No client JRE required.

  • Multilingual JSP page

    I am trying to build a multilingual web page using ResourceBundle class.
    What I want is to have the table title to be multilingual. I have defined
    two properties files "title_en_US.properties" and "title_zh_CN.properties".
    I have earlier used the native2ascii tool to convert the chinese characters
    to string as shown below for the chinese properties file
    name=\u00e5\u00b8\ufffd\u00e5\ufffd\u00b7
    In my "Load.jsp", I notice that in IE 5.5 it will display
    the chinese title as garbage character as the page content type
    is defaulted to Western ISO language encoding.
    If I manually change encoding to Unicode using via the IE menu with
    steps "View/Encoding/Unicode", the garbage characters becomes Chinese.
    I tried to have another JSP "LoadUTF8.jsp" which specifies the page encoding
    as UTF-8. The IE browser shows the page encoding defaults to Unicode but
    the chinese title is still displayed as garbage characters.
    Where did I go wrong? Any help on this is much appreciated.
    Thank you.
    Regards,
    Chee Keong
    Here is a brief code of the "Load.jsp" JSP
    <%@ page language="java" contentType="text/html" %>
    <%@ page import="java.util.Locale" %>
    <%@ page import="java.util.ResourceBundle" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <!-- Load.jsp -->
    <%
    Locale mylocale = null;
    String language = request.getParameter("lang");
    if ("zh".equalsIgnoreCase(language))
    mylocale = new Locale("zh","CN");
    else
    mylocale = new Locale("en","US");
    ResourceBundle bundle = ResourceBundle.getBundle("title", mylocale);
    %>
    <head>
    <title>Testing</title>
    </head>
    <body>
    <h3> Welcome </h3>
    <table border="1">
    <tr><td><%= bundle.getString("name") %></td></tr>
    </table>
    </body>
    </html>
    Here is a brief code of the "LoadUTF8.jsp" JSP
    <%@ page contentType='text/html; charset=UTF-8' %>
    <%@ page import="java.util.Locale" %>
    <%@ page import="java.util.ResourceBundle" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <!-- LoadUTF8.jsp -->
    <%
    Locale mylocale = null;
    String language = request.getParameter("lang");
    if ("zh".equalsIgnoreCase(language))
    mylocale = new Locale("zh","CN");
    else
    mylocale = new Locale("en","US");
    ResourceBundle bundle = ResourceBundle.getBundle("title", mylocale);
    %>
    <head>
    <title>Testing</title>
    </head>
    <body>
    <h3> Welcome </h3>
    <table border="1">
    <tr><td><%= bundle.getString("name") %></td></tr>
    </table>
    </body>
    </html>

    I'm not sure what is wrong with your code, but here's a test JSP page I was using to test Chinese input and display:
    <%@ page language="java" contentType="text/html; charset=UTF-8" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
         <title></title>
         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
         <meta name="Generator" content="TextPad 4.0" />
         <meta name="Author" content="" />
         <meta name="Keywords" content="" />
         <meta name="Description" content="" />
    </head>
    <body bgcolor="#ffffff" background="" text="#000000" link="#ff0000" vlink="#800000" alink="#ff00ff">
    <%
    request.setCharacterEncoding("UTF-8");
    String str = "\u7528\u6237\u540d";
    String name = request.getParameter("name");
    if(name != null) {
         // instead of setCharacterEncoding...
         //name = new String(name.getBytes("ISO8859_1"), "UTF8");
    System.out.println(application.getRealPath("/"));
    System.out.println(application.getRealPath("/src"));
    %>
    req enc: <%= request.getCharacterEncoding() %><br />
    rsp enc: <%= response.getCharacterEncoding() %><br />
    str: <%= str %><br />
    name: <%= name %><br />
    <form method="GET" action="_lang.jsp" encoding="UTF-8">
    Name: <input type="text" name="name" value="" >
    <input type="submit" name="submit" value="Submit" />
    </form>
    </body>
    </html>

  • Accessing an Activex Component in JSP page

    Hi,
    I am trying to disable header and footer of window's page setup. I am doing that successfully with HTML page. Where as while i am trying the same with JSP it is not disabling the Header and Footer. The code is as shown below :
    <script type="text/vbscript">
    Dim WSHShell
    Set WSHShell = CreateObject("WScript.Shell")
    WSHShell.RegWrite "HKCU\Software\Microsoft\Internet Explorer\PageSetup\header", ""
    WSHShell.RegWrite "HKCU\Software\Microsoft\Internet Explorer\PageSetup\footer", ""
    </script>
    I think it is not recognizing VBscript.
    Can anybody tell me how to disable the Header and Footer with JSP page.
    Thanks and Best Regards,

    Per the specification, I have set the application
    level resource
    bundle
    as follows:
    <application>
    <message-bundle>com.awolart.MessageResources</message->
    <locale-config>
    <default-locale>en</default-locale>
    </locale-config>
    </application>However, I can not find any references in the
    specification on how to
    access this resource bundle in a jsp.The <message-bundle> element is only useful if you want to override the message strings for the standard conversion and validation error messages produced by the JavaServer Faces implementation (they tell the implementation where to find the replacement text). It is unnecessary to specify this for application-specific resource bundles.
    Craig McClanahan

  • How to print new line in jsp page

    hi
    how to print new line in jsp page
    thanks

    \n - new line character is in java specific not HTML
    specific.Well, if the correct line separator sequence (by far not always \n) would be used, it does add a new line to the HTML output. Too bad that you don't want to see HTML but formatted text. The BR tag is a formatting element for the displayed text, not a line break in HTML. ;)

  • Retrieve values from a table of a JSP page in Servlet.

    Hello all,
    I am new in JSP servlet world, I want to create a grid on JSP page using Servlet.
    Suppose i have some records in a JSP page and This JSP page will display these records in a tabular form. And, on a button click that table data should be
    accessible in servlet,
    Now, How can i traverse among all the rows of that table of JSP page in servlet. or How can i retrieve a specific cell record of that table of JSP page in servlet.
    Can anyone please answer this.
    Thank you and regards.

    Hi,
    Create in your HTML form inputs with the same name i.e.:
    <input name="a[]" value="2" >
    <input name="a[]" value="9" >
    In your jsp page use :
    String Values[] = request.getParameterValues("a[]") ;
    This will give you a string array of two elements.
    for (int x = 0; x < Values.length; x++)
        System.out.println(Values[x]) ;
    }Will print :
    2
    9
    Hope this helps.
    Bill Moo

Maybe you are looking for

  • Safari doesn't work after Yosemite install

    I've recently installed Yosemite in my iMac*. Everything works as supposed except for Safari. Every time the computer wakes from sleep Safari does NOT work at all. It doesn't load any site. The only solution so far is to restart the iMac. any clues?

  • I have a brand new ipod touch and when setting it will not connect to my home wifi, even though it is working with all other devices

    I have a brand new, just out of the box, ipod touch that will not connec to my home wifi. The connection works with all other devices.

  • Windows 7 and BB Tour

    Once-upon-a-time, I had an XP computer and my BB Tour loved it.  When I plugged the Tour into the XP computer, the computer recognized it.  Then I upgraded to a Windows 7 (64bit) system and now my BB Tour will no longer connect.  The BB Desktop Softw

  • ABAP Query error

    Hello! can anyone help pls? I am in the process of constructing an ABAP query and I'm getting an error message which is quite puzzling.  Here's the details: I'm creating the query using an infoset constructed from logical database VAV.  When I try to

  • File Manager HD see's images on PC, will not transfer them

    All my pc specs are at my profile. With the Xoom Tablet and my old XP the tablet program File Manager HD works great. I had it working with my new HP Pavilion 23 desktop but then I had to do a REFRESH. Now I'm having trouble sharing. I have tried all