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 ?
Thanks,Fabio
(f dot fornaro at inwind dot it)
-
JSP & JavaScript (2 messages)
- Posted by: k sose
- Posted on: February 09 2001 09:06 EST
Threaded Messages (2)
- JSP & JavaScript by Rak Rak on February 09 2001 09:54 EST
- JSP & JavaScript by k sose on February 10 2001 09:37 EST
-
JSP & JavaScript[ Go to top ]
- Posted by: Rak Rak
- Posted on: February 09 2001 09:54 EST
- in response to k sose
Hope this will help...
<%@ page import="whatever.*.*,
errorPage="error.jsp"
%>
<html>
<head>
<title>Title here</title>
<jsp:useBean >
<%
//java code starts
String strJsp ="Hi I am jsp variable";
int i =10;
if (session != null) {
.......
} else {
response.sendRedirect(response.encodeRedirectURL("error.jsp?eror=Invalid+Session"));
username = "";
}
//java code starts--ends
%>
</jsp:useBean>
<script LANGUAGE="JAVASCRIPT">
//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(){
alert("hi");
}
</script>
</head>
<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()">
</form>
</body>
</html> -
JSP & JavaScript[ Go to top ]
- Posted by: k sose
- Posted on: February 10 2001 09:37 EST
- in response to Rak Rak
Yeah, that was a really good begin.
Thanks,
Fabio