Java servlet program to find larger number of given two numbers

Simple Java servlet program which accepts two numbers using the post method and displays the smaller one. 

Code:

import java.io.IOException;

import java.io.PrintWriter;

import javax.servlet.ServletException;

import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

public class server extends HttpServlet {

protected void doPost(HttpServletRequest request, HttpServletResponse response)

throws ServletException, IOException {

response.setContentType("text/html");

try (PrintWriter out = response.getWriter()) {

int sum;

int x,y;

String a = request.getParameter("num1");

String b = request.getParameter("num2");

x = Integer.parseInt(a);

y = Integer.parseInt(b);

if(x>y){

out.println("First number "+x+" is greater");

}

else{

out.println("Secnd number "+y+" is greater");

}

}

}

}

Comments

Popular posts from this blog

C program to evaluate Prefix Expression using Stack data structure

Java Program to Implement sorting algorithm using TCP on Server application

C++ program to perform data transformation Min-max and Z score Normalization