I am tried to display a message in java script using alert. It works
alert("User details saved successfully");
But, I need to display a custom message from a property file via the alert()
As you have tagged jsp in your problem, you can use a properties file to store all the messages and fetch the message from properties file and put it in the alert statement in javascript like this:
alert("<%=yourMessageToBeDisplayed %>");
Hope it helps!!
Related
I'm trying to parse a .msg file. How do I get the conversation id?
I'm using org.apache.poi.hsmf.MAPIMessage
The structure of the MSG file format is described in the MSDN library, see [MS-OXMSG]: Outlook Item (.msg) File Format.
It is stored in the 0x0F030102 property - you can see if it is set in a particular MSG file in OutlookSpy (I am its author - click OpenIMsgOnIStg button).
I have a properties file whose content would be like below
myprop=key1:value1,key2:value2
myprop2=key21:value21,key22:value22
second set
myprop3=key31:value31,key32:value32
How can I show the content on a web page and make it editable, so that, if I change the value of key2 to "value 444", it just changes that and everything else remains intact?
Apache commons configuration looks helpful but not sure how above can be accomplished
I solved it using Apache commons library.
Get Builder object.
Get Configuration object from Builder.
Iterate through all the keys and their values and you can return it as a JSON response to a web page (using controller class).
Make them editable their.
When you update one value of a key; click on save will call another method end point wherein input param would be config key and updated value. which will do config.setProperty and will do builder.save();.
By this, my property file would be updated.
Using JQuery and Spring's #ModelAndView annotation for the controller.
I'm trying to code a process in which the user clicks an icon and if a certain criteria on the DB is met, a zip file will be produced on the server containing a bunch of files, then this zip file should be sent to the browser for saving.
If the criteria isn't met, then an error message should be sent to the browser telling there isn't any file to be created and produced.
However if I use JQuery' .post method, I can receive the error message (if that is the case) but never the zip binary file.
If I use a regular Href Link I can receive the file (if that is the case) but don't know how to receive the message when the file cannot be produced.
Is there an alternative or a standard way to do this?
Thanks for your support!
-Gabriel.
You should probably split your server-side method in two:
the first one validates the criteria. If unsuccessful, it notifies of an exception, otherwise it returns a URL to the method in next point
the second one actually returns the zip file
In your frontend, the code will look something like this:
$.post(urlToPoint1, data, function(response) {
if (response.success) {
// download the file using the url provided
// (pointing to method described in point 2)
window.location.href = response.url;
}
else {
alert('whatever');
}
});
I am trying to send a dynamic link via email with the following code.
Message messageSSL = new MimeMessage(session);
int hash=1000;
String content="click here";
messageSSL.setContent(content, "text/html");
However, i have failed to generate a dynamic link.The output in the mail is in the plain text format.
Output (In the mail):
click here
Even though, the following code works and generates a link called "click here".
String content="click here";
Thanks!!
I think the problem is with backward slash. We should be using forward slash in urls. Please change and try it.
The Apache Commons Email library has some useful classes that take care of the low-level details for stuff like making HTML email work properly. Check it out:
http://commons.apache.org/proper/commons-email/
can you please enclose the link by html tag and try once.
String content="<html><body>click here </body></html>";
i am using same library and working fine for me.
please check below thread
How Can I put a HTML link Inside an email body?
In a struts2 application I want email notification is to be sent when ever a user is logged in .
I want the mail body to be Html content, with the data entered by the User in run time.
Can any one suggest suggest the best way to do it !
Foe now iam using mail.jar and iam able to send the static content easily.
But facing difficulty
1. maintaining the long HTMl code string .
2. How to substitute the values in the string with the dynamic values
Please can somebody help me with a proper solution. Or Best practice to follow in Email application !
Thanks in Advance !
You can put the email body in a properties file and read it from there.
For substitution, you can define "placeholder" in your String like {FIRSTNAME} {LASTNAME} etc., and then do a replaceAll for the dynamic portions in your code.
What u need to look into is "freemarker". Its a library and u can achieve your purpose with it.
You can use an WYSIWYG (What You See Is What You Get) Editor like CKEditor or TinyMCE, letting the user writing the html without even knowing html.
Then, after the user submitted the body, you take the output that is pure html,
and inject it into the mail body.
End of story...
Just remember to set mimetype to text/html and not to text/plain , or you will see the tags instead of their representation...