1

I am sending a mail after a save is done in DB by using Struts action. Now I need to include a link in the mail which on clicking will hit my action URL.

My dev URL is wwwdev.sakthi123.road.com.

my action path will be like

wwwdev.sakthi123.road.com/serreqsubmit.do?method=openAssignTo&statusCode='+reqStatus+'&reqId='+reqId;

So, from the mail if I click the link I need to hit this path. I need to construct a link in my Action class method while framing the message.

So how do I frame the URL?

I have tried the below:

String eol = System.getProperty("line.separator");   
message ="Please click here "+eol;
message = message + 
          httpServletRequest.getContextPath() +
          "\\serreqsubmit.do?method=openAssignTo&statusCode='+reqStatus+'&reqId='+reqId;";
Roman C
  • 49,761
  • 33
  • 66
  • 176
ashwinsakthi
  • 1,856
  • 4
  • 27
  • 56

1 Answers1

0

You could use <a href=your link URL here. Construct the URL:

String url = "http://" + request.getServerName() + ":" + request.getServerPort()  + request.getContextPath() + "/serreqsubmit.do?method=openAssignTo&statusCode=" + reqStatus + "&reqId=" + reqId;
Roman C
  • 49,761
  • 33
  • 66
  • 176
  • 1
    Yes, and ensure you are sending the mail with mimetype "text/html" instead of "text/plain", to make the link clickable. – Andrea Ligios Oct 26 '12 at 12:00
  • i have used request.getRequestUrl and then appended the query string.But thansk for reminding me to set mimetype to "text/html". – ashwinsakthi Oct 26 '12 at 12:22