postheadericon 17. Develop a Servlet which looks for cookies for username and password, and forwards to a home.jsp in case the cookies are valid and forwards to login.jsp, in case the cookies are not found or the cookies are not valid





index.jsp


<html>
<head>
<title>EX-17</title>
<style>
.abc
{
background:#ababff;
position:absolute;
top:2in;
hieght:200px;
width:300px;
left:5in;
border-style:solid;
}
</style>
</head>

<body>

<div class="abc"  id="f1">
<br>
<form method="POST" action="/Ex17/bipinrupadiya.blogspot.com">
<table align="center">
<tr>
<td>User Name : </td>
<td><input type="text" name="txtUsr"></td>
</tr>
<tr>
<td>Password :</td>
<td><input type="password" name="txtPwd"></td>
</tr>
<tr>
<td colspan=2 align=center>
<input type="checkbox" name="chkRM">
Remember Me
</td>
</tr>

<tr>
<td colspan=2 align=center>
<input type="submit" value="Login">
<input type="reset" value="Reset">
</td>
</tr>
</table>
</form>
</div>
</body>
</html>

home.jsp


<html>
<head>
<title>EX-17</title>
<style>
.abc
{
background:#ababff;
position:absolute;
top:2in;
hieght:200px;
width:300px;
left:5in;
border-style:solid;
}
</style>
</head>
<body>
<div class="abc"  id="f1">
<br>
<center>
<h1>WELCOME
<br>
</div>
</body>
</html>



Ex17.java


import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Ex17 extends HttpServlet
{
public void doGet(HttpServletRequest request,HttpServletResponse response)throws IOException,ServletException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String usr = request.getParameter("txtUsr");
String pwd = request.getParameter("txtPwd");
String RM  = request.getParameter("chkRM");

if (RM != null)
{
Cookie cookie = new Cookie(usr,pwd);
cookie.setMaxAge(60*60*24*365);// 1 Year
response.addCookie(cookie);
}
Cookie[] cookies = request.getCookies();
if (cookies != null)
{
//Cookie("bipin","rupadiya");
//Cookie(usr,pwd);
String cPwd="x";
for(int i=0; i<cookies.length; i++) //user check
{
Cookie cookie = cookies[i];
if (usr.equals(cookie.getName()))
{
cPwd=cookie.getValue();
break;
}
}
if(cPwd.equals(pwd))//password check
{
response.sendRedirect("home.jsp");
}
else
{
//out.println("<script>alert('User Name or Password is incorrect. Please Try Again');location.href='login.jsp';</script>");
response.sendRedirect("index.jsp");
}
}
}
public void doPost(HttpServletRequest request,HttpServletResponse response)throws IOException,ServletException
{
doGet(request,response);
}
}


22 comments:

velraj said...


I read like this type of article only. You mentioned more important points in this article. Thankyou for interesting article.
core java training in chennai
C Language Training in Chennai
c++ class
c c++ courses in chennai
C Language Training
javascript course in chennai
Appium Training in Chennai
JMeter Training in Chennai

kiruthika said...

Very interesting post! Thanks for sharing your experience suggestions.
Aviation Academy in Chennai
Air hostess training in Chennai
Airport management courses in Chennai
Ground staff training in Chennai
Aviation Courses in Chennai
air hostess academy in Chennai
Airport Management Training in Chennai
airport ground staff training in Chennai

Anbarasan14 said...

Fabulous post. Irrespective of the age groups your post is liked by all. Thanks for sharing.

IELTS Coaching in Mulund
IELTS Training in Mulund West
IELTS Courses in Mulund
IELTS Coaching Centres in Mulund
Spoken English Class in Chennai
Spoken English in Chennai
IELTS Coaching in Chennai

Christoper stalin said...

Thanks for sharing this information.
web designing course with placement
php mysql course in chennai
magento 2 course | magento 2 training

zuan said...

Thanks for sharing an informative blog keep rocking bring more details.I like the helpful info you provide in your articles. I’ll bookmark your weblog and check again here regularly. I am quite sure I will learn much new stuff right here! Good luck for the next!
web designing and development course training institute in Chennai with placement
mobile application development training course in chennai
data science course in chennai

Rajesh said...

Nice information, want to know about Selenium Training In Chennai
Selenium Training In Chennai
Data Science Training In Chennai
Protractor Training in Chennai
jmeter training in chennai
Rpa Training Chennai
Rpa Course Chennai
Selenium Training institute In Chennai
Python Training In Chennai

Rajesh said...

Rpa Training in Chennai
Rpa Course in Chennai
Blue prism training in Chennai

Rajesh said...

Data Science Training In Chennai
Data Science Course In Chennai
Data Science Course In Chennai

Chris Hemsworth said...

The article is so informative. This is more helpful for our
best software testing training in chennai
best software testing training institute in chennai with placement
software testing training
courses

software testing training and placement
software testing training online
software testing class
software testing classes in chennai
best software testing courses in chennai
automation testing courses in chennai
Thanks for sharing.

Naveen S said...

This is the first & best article to make me satisfied by presenting good content. I feel so happy and delighted. Thank you so much for this article.

Learn Best Digital Marketing Course in Chennai

Digital Marketing Course Training with Placement in Chennai

Best Big Data Course Training with Placement in Chennai

Big Data Analytics and Hadoop Course Training in Chennai

Best Data Science Course Training with Placement in Chennai

Data Science Online Certification Course Training in Chennai

Learn Best Android Development Course Training Institute in Chennai

Android Application Development Programming Course Training in Chennai

Learn Best AngularJS 4 Course Online Training and Placement Institute in Chennai

Learn Digital Marketing Course Training in Chennai

Digital Marketing Training with Placement Institute in Chennai

Learn Seo Course Training Institute in Chennai

Learn Social Media Marketing Training with Placement Institute in Chennai

zuan said...

Thanks for sharing an informative blog keep rocking bring more details.I like the helpful info you provide in your articles. I’ll bookmark your weblog and check again here regularly. I am quite sure I will learn much new stuff right here! Good luck for the next!
Web Designing Training Institute in Chennai | web design training class in chennai | web designing course in chennai with placement
Mobile Application Development Courses in chennai
Data Science Training in Chennai | Data Science courses in Chennai
Professional packers and movers in chennai | PDY Packers | Household Goods Shifting
Web Designing Training Institute in Chennai | Web Designing courses in Chennai
Google ads services | Google Ads Management agency
Web Designing Course in Chennai | Web Designing Training in Chennai

priya said...

best php training in chennai
best php developer institution chennai
best php training with placement in chennai
best php training center in chennai
best php course in chennai

priya said...

Great work!
NIce Blog
appium online training
appium training centres in chennai
best appium training institute in chennnai
apppium course
mobile appium in chennnai
mobile training in chennnai
appium training institute in chennnai

priya said...

Have a nice blog
Thank for sharing Information
php online training in chennai
php programming center in chennai
php class in chennnai
php certification course
php developer training institution chennai
php training in chennnai
php mysql course in chennai
php institute in chennnai
php course in chennnai
php training with placement in chennnai
php developer course

mindreader said...

Thanks for the interesting blog that you have implemented here. Very helpful and innovative. Waiting for your next upcoming article.
Java Training in Chennai
Java Training Institute in Chennai
Java course in chennai
Java Training classes
Java Training
Java programming classes
core Java course

w3webschool said...

I feel satisfied to read your blog, you have been delivering a useful & unique information to our vision.keep blogging.
Digital Marketing Course In Kolkata

chandhran said...

Nice blog, I am really happy to read your blog. Thanks for sharing your blog.
AWS Training in Bangalore
AWS Training in Chennai
AWS Course in Bangalore
Best AWS Training in Bangalore
AWS Training Institutes in Bangalore
AWS Certification Training in Bangalore
Data Science Courses in Bangalore
DevOps Training in Bangalore
PHP Training in Bangalore
DOT NET Training in Bangalore

shreekavi said...

Wonderful blog. It is really informative to all.keep update more information about this
IELTS Coaching in Chennai
IELTS Coaching in Bangalore
IELTS Coaching centre in coimbatore
IELTS Coaching in madurai
IELTS Coaching in Hyderabad
ielts training in marathahalli
IELTS Classes in Bangalore
IELTS Coaching in BTM
German Classes in Bangalore
Selenium Training in Bangalore

sasi said...

Great experience for me by reading this blog. Thank you for the wonderful article.
Angularjs course in Chennai
Angularjs Training in Bangalore
angular training in bangalore
Angular Training in hyderabad
angular course in bangalore
angularjs training in marathahalli
Web Designing Course in bangalore
python training in Bangalore
angularjs training institute in bangalore
best angularjs training in bangalore


Unknown said...

Thanks for the interesting blog that you have implemented here. Very helpful and innovative. Waiting for your next upcoming article.
Mobile app development training
App development training
Mobile app development course
Mobile development course
Mobile application development course
Learn mobile application development

Unknown said...

Hello! I could have sworn I’ve been to this site before but after looking at some of the articles blog I realized it’s new to me. Anyhow, I’m definitely pleased I stumbled upon it and I’ll be book-marking it and checking back regularly!

pratheep said...

Thank you for taking the time and sharing this information with us. It was indeed very helpful and insightful while being straight forward and to the point.

Robotic Process Automation (RPA) Training in Chennai | Robotic Process Automation (RPA) Training in anna nagar | Robotic Process Automation (RPA) Training in omr | Robotic Process Automation (RPA) Training in porur | Robotic Process Automation (RPA) Training in tambaram | Robotic Process Automation (RPA) Training in velachery

Follow by Email

Total Pageviews

© BipinRupadiya.com. Powered by Blogger.