upwd->在名为(index.html)的HTML页面的登录页面中引用输入的密码
rpwd->在同一HTML页面的登录页面中引用重新输入的密码
//-->Code in servlet
if(upwd.equals(rpwd))
{
//database connectivity of a login form
}
else
{
response.sendRedirect("index.html");
//index.html is the name of the html page where im redirecting.
}
由于我正在servlet中进行验证。现在,如何在HTML(index.html)中生成一个警告框,说明密码与Servelet不匹配。
答案 0 :(得分:0)
从这里有两种方法来生成带有消息
的<?php
$cookie_file = '/tmp/checkcookie';
$url = "https://example.com/someparameter=value";
$ip = '10.18.25.123';
$msisdn = '9878656565';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-Forwarded-For: $ip','MSISDN: $msisdn'));
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
echo $response = curl_exec($ch);
?>
第一种方法:将以下html代码放入index.html文件
alert
第二种方法::从servlet生成警报,然后重定向到您的HTML页面
alert("password didn't matched !");
您甚至可以阅读:How to show alert in a jsp from a servlet and then redirect to another jsp?希望对您有所帮助