#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    USA
    Posts
    12
    Rep Power
    0

    Can Servlets work with Java Scripts?


    I would really appreciate if someone can answer this question ASAP.

    Can Servlets work with Java Scripts?
    The same Script I put in an HTML file (and it works) it does not work under servlets if I do the following

    .....

    out.println("<head>");
    out.println("<script language=\"JavaScript\">");
    out.println("<!-- function warp() {");
    out.println("var ok=confirm('Please update the response for the Conference')");
    out.println("if (ok)");
    out.println("location=\"http://www.geocities.com\"");
    out.println("}");
    out.println("warp()");
    out.println("//-->");
    out.println("</script>");

    String title = rbL.getString("requestparams.title");out.println("<title>" + title + "</title>");
    out.println("</head>");
    out.println("<body onLoad=\"javascript:warp('')\" link=\"#000066\" bgcolor=\"#DFE2FD\">");

    .....


    Thanks !!!
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    Windsor ON, Canada
    Posts
    462
    Rep Power
    14
    java script is client side. jsp/servlets are server side. the servlet generates output, in this case and as usual the output is html. that is sent to the client and would execute in their browser. hopefully that made some sense . i'm hoping that you are not trying to execute the java script inside the servlet. the script is sent as part of the output to the client. if it is not running then there must be something wrong with how you are writing it. view the source of the web page and see if the java script is correct.

IMN logo majestic logo threadwatch logo seochat tools logo