0

Hello Every one,
please tell me how to use dotproperty file in jsp?
like i m trying to code a login page and i want if any user input wrong or null value so on the same page msg should come like please enter correct username or something like that.....


please help me.....

3
Contributors
5
Replies
6
Views
8 Years
Discussion Span
Last Post by pandeyprashant
0

Please tell me site from where i can get example code so ithat i can get it easily...
please help me.

0

localization.jsp - put this file in public folder (anywhere but outside the WEB-INF).

<%@ page language="java" pageEncoding="ISO-8859-1" %>
<%@ taglib uri="/WEB-INF/c-rt.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/x-rt.tld" prefix="x" %>
<%@ taglib uri="/WEB-INF/fmt-rt.tld" prefix="fmt" %>
<html>
<body>
<form>
  Language <select name="cnt">
               <option value="hi_IN">Hindi</option>
               <option value="en_GB">English</option>
           </select>
           <input type="submit" value="Select">
</form>
<fmt:setLocale value="${param.cnt}"/>
    <fmt:setBundle basename="labels"/>
    <h2>Survey</h2>
    <form action="">
    <table>
      <tr>
        <td><fmt:message key="name"/></td>
        <td><input type="text" size="16"></td>
      </tr>
      <tr>
        <td><fmt:message key="age"/></td>
        <td><input type="text" size="16"></td>
      </tr>
      <tr>
        <td><fmt:message key="loc"/></td>
        <td><input type="text" size="16"></td>
      </tr>
      <tr>
        <td><input type="submit" value='<fmt:message key="submit"/>'></td>
      </tr>
    </table>
    </form>
  </body>
</html>

Create .properties file into WEB-INF/classes folder. Name of property file is user-defined. In this example, I have used "labels".
See this code,
<fmt:setBundle basename="labels"/>

for english culture a property file name should be,
labels_en.properties
for other cultures change the suffix en and create a new property file,
for example, hindi (indian) culture,
labels_hi.properties

Content of labels_en.properties

name=What is your name?
age=How old are you?
loc=Where do you live?
submit=Send
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.