SlideShare a Scribd company logo
1 of 5
Multiple Submit Button Test App
Contains:
1. SubmitSrv.java
2. Index.html
3. web.xml
note: it is a web app so use the codes by forming web-modules and
paste the codes there and enjoy.
1. SubmitSrv.java codes
package com.nt;
importjava.io.IOException;
importjava.io.PrintWriter;
importjava.util.Date;
importjava.util.Properties;
importjavax.servlet.ServletException;
importjavax.servlet.annotation.WebServlet;
importjavax.servlet.http.HttpServlet;
importjavax.servlet.http.HttpServletRequest;
importjavax.servlet.http.HttpServletResponse;
/**
* ServletimplementationclassSubmitSrv
*/
@WebServlet("/SubmitSrv")
publicclassSubmitSrvextendsHttpServlet{
private staticfinal longserialVersionUID=1L;
/**
* Defaultconstructor.
*/
publicSubmitSrv() {
//TODO Auto-generatedconstructorstub
}
/**
* @see HttpServlet#doGet(HttpServletRequestrequest,HttpServletResponse response)
*/
publicvoiddoGet(HttpServletRequestrequest,HttpServletResponse response) throws
ServletException,IOException{
//general setings
PrintWriterpw=response.getWriter();
response.setContentType("text/html");
//requestprocessinglogicfordifferentoperations
Stringpval=request.getParameter("s1");
//logicforseparate submit execution
if(pval.equals("ADD")){
intval1=Integer.parseInt(request.getParameter("t1"));
intval2=Integer.parseInt(request.getParameter("t2"));
pw.println("Additionis:"+(val1+val2));
}
else if(pval.equals("SUB")){
intval1=Integer.parseInt(request.getParameter("t1"));
intval2=Integer.parseInt(request.getParameter("t2"));
pw.println("Additionis:"+(val1-val2));
}
else if(pval.equals("MUL")){
intval1=Integer.parseInt(request.getParameter("t1"));
intval2=Integer.parseInt(request.getParameter("t2"));
pw.println("Additionis:"+(val1*val2));
}
else if(pval.equals("link1")){
pw.println(System.getProperties());
}
else{
pw.println(newDate());
}
//close stream
pw.close();
}
/**
* @see HttpServlet#doPost(HttpServletRequestrequest,HttpServletResponseresponse)
*/
publicvoiddoPost(HttpServletRequestrequest,HttpServletResponseresponse)throws
ServletException,IOException{
doGet(request,response);
}
}
Index.html codes
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="surl">
<div align="center">
<table>
<tr>
<td>Value 1: <input type="text" name="t1"><br></br>
Value 2: <input type="text" name="t2"><br></br></td>
</tr>
<tr align="center">
<td>
<input type="submit" name="s1" value="ADD">
<input type="submit" name="s1" value="SUB">
<input type="submit" name="s1" value="MUL">
</td>
</tr>
<tr>
<td><a href="surl?s1=link1">System
Properties</a>&nbsp;&nbsp;&nbsp;
<a href="surl?s1=link2">System Date</a>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
Web.xml codes
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-
instance" xmlns:web="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name>MultipleSubmitBtnTestApp</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>testapp</servlet-name>
<servlet-class>com.nt.SubmitSrv</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>testapp</servlet-name>
<url-pattern>/surl</url-pattern>
</servlet-mapping>
</web-app>

More Related Content

What's hot

Designing an effective hybrid apps automation framework
Designing an effective hybrid apps automation frameworkDesigning an effective hybrid apps automation framework
Designing an effective hybrid apps automation frameworkAndrea Tino
 
Selenium RC - Web Application Testing Tool
Selenium RC - Web Application Testing ToolSelenium RC - Web Application Testing Tool
Selenium RC - Web Application Testing ToolAtsushi Sano
 
Akmal Khaleeq Waheed - Challenge 3 p3
Akmal Khaleeq Waheed - Challenge 3 p3Akmal Khaleeq Waheed - Challenge 3 p3
Akmal Khaleeq Waheed - Challenge 3 p3tovmug
 
Reactive application using meteor
Reactive application using meteorReactive application using meteor
Reactive application using meteorSapna Upreti
 
MuleSoft ESB Testing Mule Application using MUnit Test Suite
MuleSoft ESB Testing Mule Application using MUnit Test SuiteMuleSoft ESB Testing Mule Application using MUnit Test Suite
MuleSoft ESB Testing Mule Application using MUnit Test Suiteakashdprajapati
 
Introduction to Automation Testing and Selenium overiew
Introduction to Automation Testing and Selenium overiewIntroduction to Automation Testing and Selenium overiew
Introduction to Automation Testing and Selenium overiewDisha Srivastava
 
How to configure Appium with android IDE & eclipse
How to configure Appium with android IDE & eclipseHow to configure Appium with android IDE & eclipse
How to configure Appium with android IDE & eclipseHaitham Refaat
 
Force.com Migration Tool
Force.com Migration ToolForce.com Migration Tool
Force.com Migration ToolAtul Gupta(8X)
 
Web Test Automation with Selenium
Web Test Automation with SeleniumWeb Test Automation with Selenium
Web Test Automation with Seleniumvivek_prahlad
 
How to Configure Selenium WebDriver (java)
How to Configure Selenium WebDriver (java)How to Configure Selenium WebDriver (java)
How to Configure Selenium WebDriver (java)Dasun Eranthika
 
Mobile Testing with Selenium 2 by Jason Huggins
Mobile Testing with Selenium 2 by Jason HugginsMobile Testing with Selenium 2 by Jason Huggins
Mobile Testing with Selenium 2 by Jason HugginsSauce Labs
 

What's hot (19)

Designing an effective hybrid apps automation framework
Designing an effective hybrid apps automation frameworkDesigning an effective hybrid apps automation framework
Designing an effective hybrid apps automation framework
 
Selenium RC - Web Application Testing Tool
Selenium RC - Web Application Testing ToolSelenium RC - Web Application Testing Tool
Selenium RC - Web Application Testing Tool
 
Akmal Khaleeq Waheed - Challenge 3 p3
Akmal Khaleeq Waheed - Challenge 3 p3Akmal Khaleeq Waheed - Challenge 3 p3
Akmal Khaleeq Waheed - Challenge 3 p3
 
Reactive application using meteor
Reactive application using meteorReactive application using meteor
Reactive application using meteor
 
Spring diy projects
Spring diy projectsSpring diy projects
Spring diy projects
 
MuleSoft ESB Testing Mule Application using MUnit Test Suite
MuleSoft ESB Testing Mule Application using MUnit Test SuiteMuleSoft ESB Testing Mule Application using MUnit Test Suite
MuleSoft ESB Testing Mule Application using MUnit Test Suite
 
Selenium Overview
Selenium OverviewSelenium Overview
Selenium Overview
 
Introduction to Automation Testing and Selenium overiew
Introduction to Automation Testing and Selenium overiewIntroduction to Automation Testing and Selenium overiew
Introduction to Automation Testing and Selenium overiew
 
QSpiders - Selenium Webdriver
QSpiders - Selenium WebdriverQSpiders - Selenium Webdriver
QSpiders - Selenium Webdriver
 
Selenium Webdriver
Selenium WebdriverSelenium Webdriver
Selenium Webdriver
 
Selenium
SeleniumSelenium
Selenium
 
Automation Testing by Selenium Web Driver
Automation Testing by Selenium Web DriverAutomation Testing by Selenium Web Driver
Automation Testing by Selenium Web Driver
 
Cucumber with appium
Cucumber with appiumCucumber with appium
Cucumber with appium
 
How to configure Appium with android IDE & eclipse
How to configure Appium with android IDE & eclipseHow to configure Appium with android IDE & eclipse
How to configure Appium with android IDE & eclipse
 
Force.com Migration Tool
Force.com Migration ToolForce.com Migration Tool
Force.com Migration Tool
 
Web Test Automation with Selenium
Web Test Automation with SeleniumWeb Test Automation with Selenium
Web Test Automation with Selenium
 
QSpiders - Automation using Selenium
QSpiders - Automation using SeleniumQSpiders - Automation using Selenium
QSpiders - Automation using Selenium
 
How to Configure Selenium WebDriver (java)
How to Configure Selenium WebDriver (java)How to Configure Selenium WebDriver (java)
How to Configure Selenium WebDriver (java)
 
Mobile Testing with Selenium 2 by Jason Huggins
Mobile Testing with Selenium 2 by Jason HugginsMobile Testing with Selenium 2 by Jason Huggins
Mobile Testing with Selenium 2 by Jason Huggins
 

Similar to Multiple Submit Button Test App

Wicket And Swing From One Codebase
Wicket And Swing From One CodebaseWicket And Swing From One Codebase
Wicket And Swing From One Codebasejcompagner
 
Google Web Toolkits
Google Web ToolkitsGoogle Web Toolkits
Google Web ToolkitsYiguang Hu
 
Top 10 Mistakes AngularJS Developers Make
Top 10 Mistakes AngularJS Developers MakeTop 10 Mistakes AngularJS Developers Make
Top 10 Mistakes AngularJS Developers MakeMark Meyer
 
4th semester project report
4th semester project report4th semester project report
4th semester project reportAkash Rajguru
 
WinAppDriver - Windows Store Apps Test Automation
WinAppDriver - Windows Store Apps Test AutomationWinAppDriver - Windows Store Apps Test Automation
WinAppDriver - Windows Store Apps Test AutomationJeremy Kao
 
Java Advance 4deleteQuery.PNGJava Advance 4deleteQuerySucc.docx
Java Advance 4deleteQuery.PNGJava Advance 4deleteQuerySucc.docxJava Advance 4deleteQuery.PNGJava Advance 4deleteQuerySucc.docx
Java Advance 4deleteQuery.PNGJava Advance 4deleteQuerySucc.docxpriestmanmable
 
Testing Microservices
Testing MicroservicesTesting Microservices
Testing MicroservicesAnil Allewar
 
I really need help on this question.Create a program that allows t.pdf
I really need help on this question.Create a program that allows t.pdfI really need help on this question.Create a program that allows t.pdf
I really need help on this question.Create a program that allows t.pdfamitbagga0808
 
20150516 modern web_conf_tw
20150516 modern web_conf_tw20150516 modern web_conf_tw
20150516 modern web_conf_twTse-Ching Ho
 
Android Meetup Slovenija #3 - Testing with Robolectric by Ivan Kust
Android Meetup Slovenija #3 - Testing with Robolectric by Ivan KustAndroid Meetup Slovenija #3 - Testing with Robolectric by Ivan Kust
Android Meetup Slovenija #3 - Testing with Robolectric by Ivan KustInfinum
 
Vue 2.0 + Vuex Router & Vuex at Vue.js
Vue 2.0 + Vuex Router & Vuex at Vue.jsVue 2.0 + Vuex Router & Vuex at Vue.js
Vue 2.0 + Vuex Router & Vuex at Vue.jsTakuya Tejima
 
Selenium-Browser-Based-Automated-Testing-for-Grails-Apps
Selenium-Browser-Based-Automated-Testing-for-Grails-AppsSelenium-Browser-Based-Automated-Testing-for-Grails-Apps
Selenium-Browser-Based-Automated-Testing-for-Grails-Appschrisb206 chrisb206
 

Similar to Multiple Submit Button Test App (20)

Wicket And Swing From One Codebase
Wicket And Swing From One CodebaseWicket And Swing From One Codebase
Wicket And Swing From One Codebase
 
Java Servlets & JSP
Java Servlets & JSPJava Servlets & JSP
Java Servlets & JSP
 
Google Web Toolkits
Google Web ToolkitsGoogle Web Toolkits
Google Web Toolkits
 
Browser_Stack_Intro
Browser_Stack_IntroBrowser_Stack_Intro
Browser_Stack_Intro
 
Top 10 Mistakes AngularJS Developers Make
Top 10 Mistakes AngularJS Developers MakeTop 10 Mistakes AngularJS Developers Make
Top 10 Mistakes AngularJS Developers Make
 
Spring REST Request Validation
Spring REST Request ValidationSpring REST Request Validation
Spring REST Request Validation
 
4th semester project report
4th semester project report4th semester project report
4th semester project report
 
WinAppDriver - Windows Store Apps Test Automation
WinAppDriver - Windows Store Apps Test AutomationWinAppDriver - Windows Store Apps Test Automation
WinAppDriver - Windows Store Apps Test Automation
 
Intro react js
Intro react jsIntro react js
Intro react js
 
Java Advance 4deleteQuery.PNGJava Advance 4deleteQuerySucc.docx
Java Advance 4deleteQuery.PNGJava Advance 4deleteQuerySucc.docxJava Advance 4deleteQuery.PNGJava Advance 4deleteQuerySucc.docx
Java Advance 4deleteQuery.PNGJava Advance 4deleteQuerySucc.docx
 
Testing Microservices
Testing MicroservicesTesting Microservices
Testing Microservices
 
I really need help on this question.Create a program that allows t.pdf
I really need help on this question.Create a program that allows t.pdfI really need help on this question.Create a program that allows t.pdf
I really need help on this question.Create a program that allows t.pdf
 
AJppt.pptx
AJppt.pptxAJppt.pptx
AJppt.pptx
 
20150516 modern web_conf_tw
20150516 modern web_conf_tw20150516 modern web_conf_tw
20150516 modern web_conf_tw
 
C#on linux
C#on linuxC#on linux
C#on linux
 
Android Meetup Slovenija #3 - Testing with Robolectric by Ivan Kust
Android Meetup Slovenija #3 - Testing with Robolectric by Ivan KustAndroid Meetup Slovenija #3 - Testing with Robolectric by Ivan Kust
Android Meetup Slovenija #3 - Testing with Robolectric by Ivan Kust
 
Vue js and Dyploma
Vue js and DyplomaVue js and Dyploma
Vue js and Dyploma
 
Vue 2.0 + Vuex Router & Vuex at Vue.js
Vue 2.0 + Vuex Router & Vuex at Vue.jsVue 2.0 + Vuex Router & Vuex at Vue.js
Vue 2.0 + Vuex Router & Vuex at Vue.js
 
Selenium-Browser-Based-Automated-Testing-for-Grails-Apps
Selenium-Browser-Based-Automated-Testing-for-Grails-AppsSelenium-Browser-Based-Automated-Testing-for-Grails-Apps
Selenium-Browser-Based-Automated-Testing-for-Grails-Apps
 
Servlets
ServletsServlets
Servlets
 

More from Peeyush Ranjan

More from Peeyush Ranjan (10)

Multiple Hyperlinks App
Multiple Hyperlinks AppMultiple Hyperlinks App
Multiple Hyperlinks App
 
Photo Insert and Retrieve App
Photo Insert and Retrieve AppPhoto Insert and Retrieve App
Photo Insert and Retrieve App
 
Scrollable Test App
Scrollable Test AppScrollable Test App
Scrollable Test App
 
Scrollable Demo App
Scrollable Demo AppScrollable Demo App
Scrollable Demo App
 
Cursor Demo App
Cursor Demo AppCursor Demo App
Cursor Demo App
 
Batch processing Demo
Batch processing DemoBatch processing Demo
Batch processing Demo
 
Transaction Management Tool
Transaction Management ToolTransaction Management Tool
Transaction Management Tool
 
Net Beans Codes for Student Portal
Net Beans Codes for Student PortalNet Beans Codes for Student Portal
Net Beans Codes for Student Portal
 
TextSearch
TextSearchTextSearch
TextSearch
 
DBTool
DBToolDBTool
DBTool
 

Multiple Submit Button Test App

  • 1. Multiple Submit Button Test App Contains: 1. SubmitSrv.java 2. Index.html 3. web.xml note: it is a web app so use the codes by forming web-modules and paste the codes there and enjoy. 1. SubmitSrv.java codes package com.nt; importjava.io.IOException; importjava.io.PrintWriter; importjava.util.Date; importjava.util.Properties; importjavax.servlet.ServletException; importjavax.servlet.annotation.WebServlet; importjavax.servlet.http.HttpServlet; importjavax.servlet.http.HttpServletRequest; importjavax.servlet.http.HttpServletResponse; /** * ServletimplementationclassSubmitSrv */ @WebServlet("/SubmitSrv") publicclassSubmitSrvextendsHttpServlet{ private staticfinal longserialVersionUID=1L; /**
  • 2. * Defaultconstructor. */ publicSubmitSrv() { //TODO Auto-generatedconstructorstub } /** * @see HttpServlet#doGet(HttpServletRequestrequest,HttpServletResponse response) */ publicvoiddoGet(HttpServletRequestrequest,HttpServletResponse response) throws ServletException,IOException{ //general setings PrintWriterpw=response.getWriter(); response.setContentType("text/html"); //requestprocessinglogicfordifferentoperations Stringpval=request.getParameter("s1"); //logicforseparate submit execution if(pval.equals("ADD")){ intval1=Integer.parseInt(request.getParameter("t1")); intval2=Integer.parseInt(request.getParameter("t2")); pw.println("Additionis:"+(val1+val2)); } else if(pval.equals("SUB")){ intval1=Integer.parseInt(request.getParameter("t1")); intval2=Integer.parseInt(request.getParameter("t2")); pw.println("Additionis:"+(val1-val2)); } else if(pval.equals("MUL")){ intval1=Integer.parseInt(request.getParameter("t1")); intval2=Integer.parseInt(request.getParameter("t2")); pw.println("Additionis:"+(val1*val2));
  • 3. } else if(pval.equals("link1")){ pw.println(System.getProperties()); } else{ pw.println(newDate()); } //close stream pw.close(); } /** * @see HttpServlet#doPost(HttpServletRequestrequest,HttpServletResponseresponse) */ publicvoiddoPost(HttpServletRequestrequest,HttpServletResponseresponse)throws ServletException,IOException{ doGet(request,response); } } Index.html codes <!DOCTYPE html> <html> <head> <meta charset="ISO-8859-1"> <title>Insert title here</title> </head>
  • 4. <body> <form action="surl"> <div align="center"> <table> <tr> <td>Value 1: <input type="text" name="t1"><br></br> Value 2: <input type="text" name="t2"><br></br></td> </tr> <tr align="center"> <td> <input type="submit" name="s1" value="ADD"> <input type="submit" name="s1" value="SUB"> <input type="submit" name="s1" value="MUL"> </td> </tr> <tr> <td><a href="surl?s1=link1">System Properties</a>&nbsp;&nbsp;&nbsp; <a href="surl?s1=link2">System Date</a> </td> </tr> </table> </div> </form>
  • 5. </body> </html> Web.xml codes <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema- instance" xmlns:web="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <display-name>MultipleSubmitBtnTestApp</display-name> <welcome-file-list> <welcome-file>index.html</welcome-file> </welcome-file-list> <servlet> <servlet-name>testapp</servlet-name> <servlet-class>com.nt.SubmitSrv</servlet-class> </servlet> <servlet-mapping> <servlet-name>testapp</servlet-name> <url-pattern>/surl</url-pattern> </servlet-mapping> </web-app>