Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


prashant khandekar
yes
1 Answer(s)      3 years and 5 months ago
Posted in : JSP-Interview Questions


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~!!!!!


Advertisement
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
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
Advertisements
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
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
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
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
support Yes Yes Flash Support Yes Yes Shockwave support Yes Yes Real Audio/Video support Yes 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
shouldAutorotateToInterfaceOrientation method ios
)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations //return YES; return (interfaceOrientation
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
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
core java
core java  Is it possible to create a shallow copy of an arraylist instance? if yes then please post the code
tech. interview
tech. interview   java support round robin algo. if yes why? and if no why
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
core java
core java  can i use native keyword with abstract method ? if yes explain and if no please explain
Inheritance
Inheritance  static methods are inherited or not?   Yes, static methods are inherited
java
java  can we make/declare static class in java? if yes ,why
Static Method in Java
Static Method in Java  Is Overriding Static methods possible in java? If Yes, How
hibernate query
hibernate query  hibernate apache par kam karta hai kya   Hi Friend, Yes. Thanks
Websphere commerce server
Websphere commerce server  Is any one working on IBM(WCS) if yes leave you mail id on this page
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
database - JDBC
database  hai friend, yes i want to use java database connection in eclipse IDE. Thanks in advance
java - Java Interview Questions
java  Is JAVA 100% OOPL??  Hi friend, Yes,Java is 100% OOPL. Thanks
Advertisements
 

 

 

DMCA.com