JSP & JavaScript


Web tier: servlets, JSP, Web frameworks: JSP & JavaScript

  1. JSP & JavaScript (2 messages)

    Hello everyone,
    I have this problem, I have a web application based on JSPs and servlets. I have to fill several form fields and control every field not to be blank before sending it to the servlet. As a project specification I cannot use a servlet or a bean to do this control, so I thought to do it using JavaScript, but I cannot figure out how to code it! Can anyone help me please sending me or here any suggestion or/and links to samples of JSP mixed with JavaScript ?
    (f dot fornaro at inwind dot it)

    Threaded Messages (2)

  2. JSP & JavaScript[ Go to top ]

    Hope this will help...

    <%@ page import="whatever.*.*,

    <title>Title here</title>
    <jsp:useBean >

    //java code starts
          String strJsp ="Hi I am jsp variable";
          int i =10;
          if (session != null) {
          } else {
             username = "";
    //java code starts--ends

    //java script variables
    var count = 0;
    //following line uses jsp var in javascript
    var fromjsp = "<%= strJsp %>";
    var uni = Math.random();

    function intialize() {
       alert("Value from JSP is" +fromjsp);

    function sayhi(){

    <body bgcolor="#DADADA" ONLOAD="javascript:intialize();" >

    <form method="post" name="from1" action="" >
    <input type="text" value="<%= strJsp %>" >
    <input type="button" name="click me" onClick="sayhi()">
  3. JSP & JavaScript[ Go to top ]

    Yeah, that was a really good begin.