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"
?