Displaying SweetAlert from Java Servlet [duplicate]












0
















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










share|improve this 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.























    0
















    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










    share|improve this 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.





















      0












      0








      0









      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










      share|improve this question















      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      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.


























          1 Answer
          1






          active

          oldest

          votes


















          0














          Just need to set the response type




          response.setContentType("text/html");




          works like charm.






          share|improve this answer






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            Just need to set the response type




            response.setContentType("text/html");




            works like charm.






            share|improve this answer




























              0














              Just need to set the response type




              response.setContentType("text/html");




              works like charm.






              share|improve this answer


























                0












                0








                0







                Just need to set the response type




                response.setContentType("text/html");




                works like charm.






                share|improve this answer













                Just need to set the response type




                response.setContentType("text/html");




                works like charm.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 26 '18 at 13:32









                AbhishekAbhishek

                199




                199

















                    Popular posts from this blog

                    Lallio

                    Futebolista

                    Jornalista