Displaying SweetAlert from Java Servlet [duplicate]
This question already has an answer here:
How to return an html document from java servlet? [duplicate]
1 answer
I wanted to use SweetAlert for one of my project, but when i use SweetAlert from servlet, it is printing the lines instead of dialouge box
print.java //My Servlet
public class print extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String city = request.getParameter("cities");
PrintWriter out = response.getWriter();
out.println(city);
out.println("<script src='https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/6.11.4/sweetalert2.all.js'></script>");
out.println("<script src='https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js'></script>");
out.println("<script src='https://unpkg.com/sweetalert/dist/sweetalert.min.js'></script");
out.println("<script>");
out.println("$(document).ready(function(){");
out.println("swal('We Will Get Back To You Soon','Thank You','info');");
out.println("});");
out.println("</script>");
}
I used Sweet Alert before from the jsp page, even with the servlets i used these. But all of sudden, now I'm encountering this. Any help would be appreciated
The output I'm getting is, it is just printing the above lines
javascript java jsp servlets sweetalert
marked as duplicate by luk2302, Community♦ Nov 26 '18 at 13:33
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
How to return an html document from java servlet? [duplicate]
1 answer
I wanted to use SweetAlert for one of my project, but when i use SweetAlert from servlet, it is printing the lines instead of dialouge box
print.java //My Servlet
public class print extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String city = request.getParameter("cities");
PrintWriter out = response.getWriter();
out.println(city);
out.println("<script src='https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/6.11.4/sweetalert2.all.js'></script>");
out.println("<script src='https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js'></script>");
out.println("<script src='https://unpkg.com/sweetalert/dist/sweetalert.min.js'></script");
out.println("<script>");
out.println("$(document).ready(function(){");
out.println("swal('We Will Get Back To You Soon','Thank You','info');");
out.println("});");
out.println("</script>");
}
I used Sweet Alert before from the jsp page, even with the servlets i used these. But all of sudden, now I'm encountering this. Any help would be appreciated
The output I'm getting is, it is just printing the above lines
javascript java jsp servlets sweetalert
marked as duplicate by luk2302, Community♦ Nov 26 '18 at 13:33
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
How to return an html document from java servlet? [duplicate]
1 answer
I wanted to use SweetAlert for one of my project, but when i use SweetAlert from servlet, it is printing the lines instead of dialouge box
print.java //My Servlet
public class print extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String city = request.getParameter("cities");
PrintWriter out = response.getWriter();
out.println(city);
out.println("<script src='https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/6.11.4/sweetalert2.all.js'></script>");
out.println("<script src='https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js'></script>");
out.println("<script src='https://unpkg.com/sweetalert/dist/sweetalert.min.js'></script");
out.println("<script>");
out.println("$(document).ready(function(){");
out.println("swal('We Will Get Back To You Soon','Thank You','info');");
out.println("});");
out.println("</script>");
}
I used Sweet Alert before from the jsp page, even with the servlets i used these. But all of sudden, now I'm encountering this. Any help would be appreciated
The output I'm getting is, it is just printing the above lines
javascript java jsp servlets sweetalert
This question already has an answer here:
How to return an html document from java servlet? [duplicate]
1 answer
I wanted to use SweetAlert for one of my project, but when i use SweetAlert from servlet, it is printing the lines instead of dialouge box
print.java //My Servlet
public class print extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String city = request.getParameter("cities");
PrintWriter out = response.getWriter();
out.println(city);
out.println("<script src='https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/6.11.4/sweetalert2.all.js'></script>");
out.println("<script src='https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js'></script>");
out.println("<script src='https://unpkg.com/sweetalert/dist/sweetalert.min.js'></script");
out.println("<script>");
out.println("$(document).ready(function(){");
out.println("swal('We Will Get Back To You Soon','Thank You','info');");
out.println("});");
out.println("</script>");
}
I used Sweet Alert before from the jsp page, even with the servlets i used these. But all of sudden, now I'm encountering this. Any help would be appreciated
The output I'm getting is, it is just printing the above lines
This question already has an answer here:
How to return an html document from java servlet? [duplicate]
1 answer
javascript java jsp servlets sweetalert
javascript java jsp servlets sweetalert
asked Nov 26 '18 at 13:21
AbhishekAbhishek
199
199
marked as duplicate by luk2302, Community♦ Nov 26 '18 at 13:33
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by luk2302, Community♦ Nov 26 '18 at 13:33
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Just need to set the response type
response.setContentType("text/html");
works like charm.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Just need to set the response type
response.setContentType("text/html");
works like charm.
add a comment |
Just need to set the response type
response.setContentType("text/html");
works like charm.
add a comment |
Just need to set the response type
response.setContentType("text/html");
works like charm.
Just need to set the response type
response.setContentType("text/html");
works like charm.
answered Nov 26 '18 at 13:32
AbhishekAbhishek
199
199
add a comment |
add a comment |