0

I have just created .properties with its values and JSP file

<%@ page pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<c:set var="language" value="${not empty param.language ? param.language :
        not empty language ? language : pageContext.request.locale}" scope="session" />
<fmt:setLocale value="${language}" />
<fmt:setBundle basename="ge.web.content.i18n.text" />
<!DOCTYPE html>

<html>
    <head>
        <title>JSP/JSTL i18n demo</title>
    </head>
    <body> 
        <a href="">ENGLISH </a> <br>
        <a href="">PARIS</a>
            <form method="post">
                <label for="username"><fmt:message key="login.label.username" />:</label>
                <input type="text" id="username" name="username">
                <br>
                <label for="password"><fmt:message key="login.label.password" />:</label>
                <input type="password" id="password" name="password">
                <br>
            <fmt:message key="login.button.submit" var="buttonValue" />
                <input type="submit" name="submit" value="${buttonValue}">
        </form> <br> text from database here.
    </body>
    </html>

Question 1) It takes the username and password from my properties file (default English). It works, but the text is not shown in the button. Key "login.label.password" is correct.

Question 2) When I click on a link, for example PARIS, I need to change text from the properties file. How can I do that? How can i change locale? I think I should write in session, because I need to change the language from the database too.

Question 3) With changing the properties file's text, I need the language text from the database too (without changing the link). How can I achieve this?

Questin 4 Should I use JSTL, or should I save the language in the session and redirect with something like this ?language="EN"?

jvdhooft
  • 657
  • 1
  • 12
  • 33
grep
  • 5,465
  • 12
  • 60
  • 112
  • Is it a legacy project? If you can I suggest you going with JSF instead of scriptlets. You're using a technology that's more than 10 years old instead of it. With JSF what you want to achieve is straight forward. – Aritz Aug 05 '13 at 21:16
  • Huh? The code example doesn't use scriptlets. – Steven Benitez Aug 06 '13 at 02:37
  • No its not big project. So I don't need JSF :-) – grep Aug 06 '13 at 08:03
  • In the future, ask one question per Question. That's easier answering and finding duplicates. The current duplicate answers your first question. – BalusC Jun 06 '16 at 07:31

0 Answers0