0% found this document useful (0 votes)
4 views

Java Programs

java programs

Uploaded by

prempalhade3
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Java Programs

java programs

Uploaded by

prempalhade3
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Input -

Index.html

<html>

<body>

<form method="get" ac on="ChRaServlet">

<input type="checkbox" name="sub">English

<input type="checkbox" name="sub">Hindi

<input type="checkbox" name="sub">Marathi

<input type="radio" name="gen">Male

<input type="radio" name="gen">Female

</form>

</body>

</html>

ChRaServlet.java

import java.io.*;

import javax.servlet.*;

import javax.servlet.h p.*;

import javax.servlet.annota on.*;

@WebServlet("/ChRaServlet")

public class ChRaServlet extends H pServlet{

public void doGet(H pServletRequest req,H pServletResponse res)throws


IOExcep on,ServletExcep on{

String l[] = req.getParameterValues("sub");

if(l!=null){

System.out.println("Subjects as");

for(String lang:l){
ti
tt
tt
ti
ti
ti
tt
tt
System.out.println("\t"+lang); }}}}

Output -

Input -

Index.html

<html>

<body>

<form method="get" ac on="PassServlet">

Percentage :<input type="number" name="p1">

<input type="submit" value="check">

</form>

</body>

</html>

PassServlet.java

import java.io.*;

import javax.servlet.*;

import javax.servlet.h p.*;

import javax.servlet.annota on.*;

@WebServlet("/PassServlet")

public class PassServlet extends H pServlet{



tt
ti
ti
tt
public void doGet(H pServletRequest req,H pServletResponse res)throws
IOExcep on,ServletExcep on{

String u1 = req.getParameter("p1");

int per = Integer.parseInt(u1);

PrintWriter pw = res.getWriter();

if(per>=40){pw.println("Pass !!");}

else if(per<=40){pw.println("Fail :(");}

pw.close();}}

Output -

Input -

Index.html

<html>

<body>

<form method="get" ac on="LogServlet">

User Name:<input type="text" name="u1"><br>

Password:<input type="password" name="p1" ><br>

<input type="submit" value="Login">

</form>

</body>

</html>

ti
tt
ti
ti

tt
LogServlet.java

import java.io.*;

import javax.servlet.*;

import javax.servlet.h p.*;

import javax.servlet.annota on.*;

@WebServlet("/LogServlet")

public class LogServlet extends H pServlet {

public void doGet(H pServletRequest req, H pServletResponse res) throws


ServletExcep on,IOExcep on

PrintWriter out = res.getWriter();

String pass="abhishek12345";

String username,password;

username=req.getParameter("u1");

password=req.getParameter("p1");

if(username.equals("uname") && password.equals(pass)) {

out.println("Login Successfull");}

else{

out.println("Login Unsuccessfull");}}}

Output :-

ti
tt
tt
ti
ti
tt

tt

You might also like