yes

yes

You hav asked "have u used "post" method"

import java.io.IOException; import java.io.PrintWriter;

import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse;

public class PatternExample extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet { /** * */ private static final long serialVersionUID = 1L;

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
{        
    response.setContentType("text/html");        
    PrintWriter out=response.getWriter();

    String number1=request.getParameter("num1");
    String number2=request.getParameter("num2");

    int n1=Integer.parseInt(number1);
    int n2=Integer.parseInt(number2);

    for(int i=n1;i<=n2;i++)
        {   
        for(int j=n1;j<i+1;j++)
        {   
                out.print(j);   
        }   
        out.println("<br>");   
        }       
    }
}

this is the servlet and;

<form method="post" action="/PatternExample">

Enter start: <input type="text" name="num1"><br>

Enter end  : <input type="text" name="num2"><br>

<input type="submit" value="Submit" onclick="PatternExample.java">



</form>

this is jsp file and i think both contain POST method so i guess it contains post method~!!!!!

View Answers

May 18, 2011 at 4:25 PM

Make changes in PatternExample.java:

import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class PatternExample extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet { 

public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html");
        PrintWriter out=response.getWriter();

String number1=request.getParameter("num1");
String number2=request.getParameter("num2");
int n1=Integer.parseInt(number1);
int n2=Integer.parseInt(number2);
for(int i=n1;i<=n2;i++){
   for(int j=n1;j<i+1;j++){
   out.print(j);
   }
   out.println("<br>");
    }
        }
        public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {
        this.doPost(request, response);
}
}

Compile your servlet. Then restart the server and then run the pattern.jsp.









Related Tutorials/Questions & Answers:
yes
ModuleNotFoundError: No module named 'yes'
ModuleNotFoundError: No module named 'yes'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'yes' How to remove the ModuleNotFoundError: No module named 'yes' error
Advertisements
javascript confirm yes no
javascript confirm yes no  javascript confirm yes no - how to create confirm dialog box yes or no in JavaScript?   if (confirm('Are You... are not redirected") }   How to confirm yes or no in JavaScript
JavaScript Alert YES NO
JavaScript Alert YES NO  How to send an alert to a user to confirm if there request is valid or not? I wants to send the alert message in Java Script.   You can use the confirm() method in Java Script. if (confirm
fast view web--yes - Struts
fast view web--yes  How to enable the fast web view--yes on pdf file  Hi Friend, Please clarify your problem. Thanks
Yes/No confirm box with vbscript - Framework
Yes/No confirm box with vbscript  I'm using a Yes/No confirmation with vbscript. But the in the confirm box, the titiel is coming along with 'VBScript' in it. I just want to remove this 'VBScript' title, Can anyone help me
[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO] is depricated
[[UIApplication sharedApplication] setStatusBarHidden:YES animated... the status bar hidden. [[UIApplication sharedApplication] setStatusBarHidden:YES...: [[UIApplication sharedApplication] setStatusBarHidden:YES]; Thanks
Access denied for user 'abc'@'xxxx' (using password: YES)
Access denied for user 'abc'@'xxxx' (using password: YES)  I have tested my code on local machine DB, its working correctly.. But when i shifted it to server DB using URL, Username and password.. i got this error .. How can i
Time Tracker
Time Tracker       Time Tracker is a simple tool to keep track of the time you spend on any task. Think of it as a to-do-list with a clock. And yes, it's free. Read full Description ADS
Struts Interview Questions
Struts Interview Questions       Question: Can I setup Apache Struts to use multiple configuration files? Answer: Yes Struts can use multiple configuration files. Here
XML Interviews Question page9
XML Interviews Question page9       Can I encode mathematics using XML ? A: Yes, if the document type you use provides for math, and your users' browsers
Social Media Marketing Services India
Do you want to be the market leader or want to see your company in the elite group in a very short span of time? If your answer is in yes, you need the power of Social Media Marketing Services. There are several powerful
Purchasing the right GPS unit
Purchasing the right GPS unit       Yes, now you can find the use of Global Positioning System in various ways including in your car, your watch, mobile phone, fleet, boat
Common Interview Questions and Their Answers.
Common Interview Questions and Their Answers.       Introduction The first step for successful interviews is to remember how you feel. Yes, it is your nth interview
Windows Web Hosting
MS FrontPage 2000, 2002 support Yes Yes Flash Support Yes Yes Shockwave support Yes Yes Real Audio/Video support Yes
tomcat
tomcat  Is it necessary to restart the server if we change the JDK path in tomcat server?   Yes, Thanks   Yes, Thanks
Ajax problem
Ajax problem  Dear sir/mam i want to ask that i am using radio button for the yes or no but i want when i use yes then inside the yes button add on one extra textbox if press no the do not required text button
String doubt replace function
String doubt replace function  What is the output and why of below : String s1 = "Hello"; if(s1.replace('H','H')== "Hello") System.out.println("yes...") System.out.println("yes"); else System.out.println
Database
Database  is it possible to view the query code after executing it.if yes tell me the procedure.   Yes, if you want to retrieve the data that is stored in database, then use the given query: select * from student
shouldAutorotateToInterfaceOrientation method ios
)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations //return YES; return (interfaceOrientation
with out class - Java Beginners
with out class  can we write a program with out a class in core java?if yes,give example
Pointer a variable
Pointer a variable  hii, Pointer is a variable or not ?   hello,ADS_TO_REPLACE_1 Yes, a pointer is a variable
multithreading
multithreading  is multithreading is inbuilt in java? if yes then why we implement thread seperately
Servlet - JSP-Servlet
Servlet  Hi, Can Servlet have instance variables.If yes please give an example. Thanks, Poonam
java - Java Interview Questions
java  Is JAVA 100% OOPL??  Hi friend, Yes,Java is 100% OOPL. Thanks
database - JDBC
database  hai friend, yes i want to use java database connection in eclipse IDE. Thanks in advance
jaavscript & ajax - Design concepts & design patterns
jaavscript & ajax  Can we give same frame for each button's functionality.if yes,how to do it Thank You
Websphere commerce server
Websphere commerce server  Is any one working on IBM(WCS) if yes leave you mail id on this page
hibernate query
hibernate query  hibernate apache par kam karta hai kya   Hi Friend, Yes. Thanks
Static Method in Java
Static Method in Java  Is Overriding Static methods possible in java? If Yes, How
java
java  can we make/declare static class in java? if yes ,why
Inheritance
Inheritance  static methods are inherited or not?   Yes, static methods are inherited
core java
core java  can i use native keyword with abstract method ? if yes explain and if no please explain
arrays
arrays  while declaring 2-d array, is it compulsary to write no of columns like C or is it different? and if yes then why
tech. interview
tech. interview   java support round robin algo. if yes why? and if no why
core java
core java  Is it possible to create a shallow copy of an arraylist instance? if yes then please post the code
java servlets - Java Beginners
java servlets  i want to close window when ever he logout from one page... this closing is done with yes/no option. when ever press "yes" it means he successfully logout from page. if press "no" it means he not logout from
javascript - Design concepts & design patterns
javascript  i want to close window when ever he logout from one page... this closing is done with yes/no option. when ever press "yes" it means he successfully logout from page. if press "no" it means he not logout from
override jspInit()
override jspInit()  Can you override jspInit() method? If yes, In which cases?   Yes, We do it usually when we need to initialize any members which are to be available for a servlet/JSP throughout its lifetime
How to match a string using the INDEX and the method use Stack or Queue?
matches: two would you like to check other string? yes or no? yes Enter...: three would you like to check other string? yes or no? yes Enter... would you like to check other string? yes or no? yes Enter a STRING
iPhone/iPad Project xCode
iPhone/iPad Project xCode  hii Can I compile the same iPhone source code for iPad?   Yes you can do so.ADS_TO_REPLACE_1 Yes. This is called a Universal binary. so you can compile the same iPhone source code for iPad
java fresher - Java Beginners
java fresher  i am working on php.can i learn JAVA.If yes,then how much time it will take  Hi Friend, Yes, you can learn java. Please visit the following link: http://www.roseindia.net/java/ Thanks
Mysql Alter Table Identity
| +----------+--------------+------+-----+---------+-------+ | username | varchar(100) | YES | | | | | fname | varchar(100) | YES | | | | | email | varchar(100) | YES
Mysql Alter Constraint
| +----------+--------------+------+-----+---------+-------+ | username | varchar(100) | YES | | | | | fname | varchar(100) | YES | | | | | email | varchar(100) | YES | | | | | count
is _array()
is _array()  is_array() in php   Hi Friend, This function is of Boolean type.It checks whether a variable is an array or not. Here is an example: <?php $yes = array('Hello', 'World'); echo is_array($yes) ? 'Array
is _array()
is _array()  is _array()   Hi Friend, This function is of Boolean type.It checks whether a variable is an array or not. Here is an example: <?php $yes = array('Hello', 'World'); echo is_array($yes) ? 'Array
javascript problem
javascript problem  hi guys My problem is that I am using radio button for yes or no but i want to do that if I press yes button then enter the text button inside the radio button if I press no button then no any other textbox
CMS project using JSF
CMS project using JSF  Can i use jsf for CMS project..? If yes pls give some guidelines to how to start
array - Java Beginners
array  Accept a two dimensional array from the user check if this array is symetric display a message yes,if it is symetric otherwise display it ,is not symetric
question on class - Java Beginners
question on class   A class can act as subclass itself? if yes give me one example if no give me one example

Ads