How to Read a Properties File in JavaScript from Project Directory

Read properties file using jQuery or JavaScript

One shouldn't use scriptlets in JSP, you can easily do it using struts2 tags.

Change your Javascript in JSP as follows :

function checkedRadioForDelete(f) {
var chx = document.getElementsByTagName('input');
for ( var i = 0; i < chx.length; i++) {
if (chx[i].type == 'radio' && chx[i].checked) {
var con = confirm("<s:text name="msg.confirm"/>");
if (con != true) {
} else {
f.action = "MyAction.action";
f.submit();
}
return true;
}
}
alert("<s:text name="msg.alert"/>");
return false;
}

Accessing a Properties File From a Different Project

Properties allProperties = new Properties();
ClassLoader loader = Thread.currentThread().getContextClassLoader();
allProperties.load(loader.getResourceAsStream("/tokens.properties"));

You were close. That's indeed the right class loader, but the wrong path. Remove the leading slash.

allProperties.load(loader.getResourceAsStream("tokens.properties"));

Is there a way to display data from properties file to HTML file?

You should handle this in the backend of your application. It is explained here:
http://justinrodenbostel.com/2014/05/13/part-4-internationalization-in-spring-boot/

Additionally, try to use Spring's standard naming i.e. messages_en.properties and messages_jp.properties



Related Topics



Leave a reply



Submit