java - Why it is showing "String literal is not properly closed by a double-quote"? -


the line @ message.setcontent() trying put html code string argument showing error "string literal not closed double-quote". please me find out why showing that.

try {       // create default mimemessage object.       mimemessage message = new mimemessage(mailsession);       mimebodypart htmlpart = new mimebodypart();       %>  <%         message.setfrom(new internetaddress(from));         message.addrecipient(message.recipienttype.to,                                new internetaddress(to));        message.setsubject("thank using our service");          message.setcontent("<table><tr><td>full name</td><td><%= name %></td></tr><tr><td>address</td><td><%= addr %></td></tr><tr><td>age</td><td><%= age %></td></tr><tr><td>qualification</td><td><%= qual %></td></tr><tr><td>percentage</td><td><%= persent %></td></tr><tr><td>year of passout</td><td><%= year %></td></tr></table>", "text/html");         transport.send(message);       result = "sent message successfully....";    } catch (messagingexception mex) {       mex.printstacktrace();       result = "error: unable send message....";    } 

the output statement <%=name%> on jsp, when compiled produces output:

out.print(name); 

now if trying inside string append name variable should use:

message.setcontent("<table><tr><td>full name</td><td>"+name+"</td></tr>.....","text/html"); 

dont forget have define somewhere name variable this:

<%string name = request.getparameter("name");%> 

or this....

...of course not how should using jsps. use of scriptlets should avoided. check out


Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -