Home Tutorialhelp Comment I want to use loop but can.t work code as follows:

 
 

Comment

pradeep
I want to use loop but can.t work code as follows:,
September 1, 2010 at 2:09 PM


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<HTML>
<HEAD>
<TITLE>Using the while Loop in jsp</TITLE>
</HEAD>

<BODY>
<H1>Using the while Loop</H1>


<%@ page import="java.io.FileInputStream" %>
<%@ page import="java.io.BufferedInputStream" %>
<%@ page import="java.io.File " %>
<%@ page import="java.io.IOException" %>



<%
int i=0;
while(i<=2)
{
String dwFilename ="C:\\downloadJSP\\raj.zip";
// set the http content type to "APPLICATION/OCTET-STREAM
response.setContentType("APPLICATION/OCTET-STREAM");

// initialize the http content-disposition header to
// indicate a file attachment with the default filename
BufferedInputStream buf=null;
ServletOutputStream myOut=null;
try {
myOut = response.getOutputStream( );
File myfile = new File(dwFilename);

//set response headers
response.setContentType("text/plain");

response.addHeader("Content-Disposition","attachment; filename="+dwFilename );

response.setContentLength( (int) myfile.length( ) );

FileInputStream input = new FileInputStream(myfile);
buf = new BufferedInputStream(input);
int readBytes = 0;

//read from the file; write to the ServletOutputStream
while((readBytes = buf.read( )) != -1)
myOut.write(readBytes);

} catch (IOException ioe){

throw new ServletException(ioe.getMessage( ));

} finally {

//close the input/output streams
if (myOut != null)
myOut.close( );
if (buf != null)
buf.close( );


}
i++;
}
%>
</BODY>
</HTML>


View All Comments | View Tutorial
Advertisement
Related Tutorial and Articles
Java Beginners

i want code for these programs
i want code for these programs   Advances in operating system Laboratory Work: (The following programs can be executed on any.... The program should make use of kernel timer to measure and print the real time, processor 

JSP-Tutorials

How to use for loop in jsp
How to use 'for' loop in jsp page ? This is detailed java code that shows how to use 'for' loop in jsp page. 'if' statement is used to test conditions while...;) { // use for loop for (int i = 0; i

Programming Tutorials

How to use 'for' loop in jsp page?
How to use 'for' loop in jsp page?   ...;) { // use for loop for (int i = 0; i <...; </html> Save this code as a .jsp file named "use 

JSP Tutorials

How to use 'for' loop in jsp page?
How to use 'for' loop in jsp page?   ...;) { // use for loop for (int i = 0; i <...; </html> Save this code as a .jsp file named "use 

Struts Questions

For Loop - Struts
For Loop  Hi, How to use for loop in Struts2. I don't want use Java code in the JSP. In my application I am using List is sending to jsp.... How to use the For loop in JSP. Thanks, Rajesh.  Hi Rajesh, i 

JSP-Tutorials

FOR Loop In JSP
about how to use for loop in JSP. In this example I will create a JSP page...FOR Loop In JSP In this section we will read about how to use the for loop... of iteration before entering the loop. For loop in JSP is used as same as it is used 

JSP Tutorials

Use while loop in jsp code
Use while loop in jsp code   ... then checks the boolean condition. Before run this jsp code create a new directory... will run 5 times.<br>"); int i = 1; // while loop 

JSP Servlet Questions

How to Work - JSP-Servlet
How to Work  Respected sir i am ramesh doing final year MCA.Now i am doing final year project using java,jsp,servlet.i only know java.i want details... to directly insert java code into jsp file, this makes the development process very 

JSP-Tutorials

JSP for loop Example
;% for loop %> Syntax of for loop in JSP page. <% Write here code%> Example...;Loop through JSP count :"+i+"<br/>"); } %> <...JSP for loop Example We are going to discus about for loop in JSP page's 

Java Tips and Examples

While Loop
the repetitious work then you use the Loop control statement. ...; statements;    } In this program you will see how to use the while loop... While Loop       Loop 

Servlet Interview Questions

i want to update values
i want to update values  in my form i have 2 submit buttons one... this code using html servlets and jsp... database and it need to insert automatically in to disabled text boxs and once i press 

Java Beginners

plsz i want the coding details of line
plsz i want the coding details of line  package vc.api; import...);//white } } } return output; } in the above code i... the for loop... that is if (template.getRGB(j,i)<-8388608) {//black 

Java Beginners

plsz i want the coding details of line
output; } in the above code i want details about the valule...plsz i want the coding details of line  package vc.api; import... second setRGB(j,i,-16777216) y can use this value...its constant one how 2 

Java Beginners

loop
loop  i want to write my name(inder) through loop in java using star 

Java Beginners

for loop
++) { System.out.println("Tick" + i); } } Here the loop is executed 10 times from 0 to 10. At first when control enters the loop the variable 'i.... The declaration of 'i' can also be done inside the "for" loop which is as follows 

Java Beginners

Loop
to understand a loop my quesiton are: what du i do wrong in my code since... dk  Hi, Please check the for loop once again: for (int i... here : i = stop; but it should be i <= stop; The correct loop would 

JSP Interview Questions

I want this jsp answers
I want this jsp answers    How can we declare third party classes and interfaces inside our jsp page? How can we declare and definr global variables... for particular jsp pages? If we want to develop any jsp pages using eclipse where we can 

JSP Interview Questions

I want this jsp answers
I want this jsp answers    How can we declare third party classes and interfaces inside our jsp page? How can we declare and definr global variables... for particular jsp pages? If we want to develop any jsp pages using eclipse where we can 

Java Beginners

Java I/O Assistance + Loop
CANNOT Get the output as I want. I know where the error lays I just can't seem... my loop I believe I just cant wrap my head around how to get a proper display...Java I/O Assistance + Loop  I'm trying to make this program write 

PHP Questions

PHP and want to use JQuery as validator
PHP and want to use JQuery as validator  I would love to make simple project with PHP and want to use JQuery as validator but i don't know how i use. Could help me showing simple code?   Here is a link 

Java Beginners

loop
loop  strong textHello can someone help me with this problem,I need to output the following code using a loop the code is as follows with the user inputs in inverted commas,thanks. ENTER CODE(XX to Stop) CODE:"D24" QUANTITY:"2 

Java Beginners

I want display frame in another frame - Java Beginners
I want display frame in another frame  Hi all, this is available... is header.jsp and another is footer.jsp I want to display footer.jsp is display... please tell me what i can do this code is given error Error 404--Not Found 

Java Beginners

want a code
want a code  I am trying to write Java code for creating a file of any type (either text,csv,or any other format). What I need is : The file generated should be zipped and password-protected. When I try to open the file, it asks 

Java Beginners

jsp code - Java Beginners
jsp code  hello sir i have a problem in in loop while(itr.hasNext... to retrieve the value of staxapp when i wana use it in entire jsp. thanks...; i want a value of staxapp here which should be hidden in every rotation 

JSP Tutorials

JSP for loop Example
will illustrate how to use for loop in JSP. Example : In this example we are going...JSP for loop Example In this section we will discuss about for loop in JSP... JSP page named  "textinput.jsp". Using for loop we will iterate 

JSP Tutorials

Use Break Statement in jsp code
Use Break Statement in jsp code   ...;H1>use break statement in jsp code</H1> <% double array... = 0; i < array.length; i++) { sum += array[i]; // use 

JSP Servlet Questions

i want code of signing off from a account how its done in jsp and servlet by using either cookies or session
i want code of signing off from a account how its done in jsp and servlet by using either cookies or session   sig 

JSP Servlet Questions

I want solution for this jsp program..
I want solution for this jsp program..   <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@ page import="java.sql.*" %> JSP Page <%! String 

JSP Servlet Questions

i use HTML in jsp - JSP-Servlet
i use HTML in jsp  i want to make a list box of select state...){ var i; for(i=selectbox.options.length-1;i>=0;i--){ //selectbox.options.remove(i); selectbox.remove(i); } } function addOption(selectbox 

JSP Servlet Questions

i want code of signing off from a account how its done in jsp and servlet by using either cookies or session
i want code of signing off from a account how its done in jsp and servlet by using either cookies or session   sig   Hi Friend, Please visit the following link: http://roseindia.net/jsp/bank.shtml Thanks 

Java Beginners

I want to display 10,000 records in a jsp page.Can I display page by page?
I want to display 10,000 records in a jsp page.Can I display page by page?  When I submit a form it says "ERROR: Query request too large. Total rows... print page by page or have say 900 records per page in a jsp? Should I have 

JSP Servlet Questions

I want code below mention programe
I want code below mention programe  Create a web application using any technology that accepts a keyword and displays 10 relevant tweets from Twitter in real-time for that keyword 

Development process Questions

i want to display where i entered values to same page
i want to display where i entered values to same page  hi friends !! i have a values from jsp page .and i want to store that values into DB at the same time i want to show immediatlly on same jsp page with tabular format 

JSP Servlet Questions

How do I change the while loop in this code to the range with range list style display page for a resultSet() in jsp?
How do I change the while loop in this code to the range with range list style display page for a resultSet() in jsp?  this is count record code...;   The given code count the number of rows in a database table. < 

Java Tips and Examples

For Loop in Java
the given variable. Such as:   i++;   j++;  Code of the program : ... For Loop in Java - Java For Loop Examples & Syntax       The for loop is the type of  looping 

Development process Questions

i want immediate code - Development process
i want immediate code  Basic sales tax is applicable at a rate of 10... of 5%, with no exemptions. When I purchase items I receive a receipt which lists...: 74.68   Hi friend, Code to help in solving the problem : import 

Java Server Faces Questions

JSP Parse did not work - Java Server Faces Questions
========================================================================== Then, I want to use another.jsp file say output.jsp...JSP Parse did not work  I have these codes...("Feedback"); out.print("Selected Values are: "); for(int i=0;i DropDown DropDown 

JSP Tutorials

JSTL for Loop <c: forEach>
as, for loop works in a jsp or in java. In this example i is the name of the variable... of the variable on the browser use <c:out> tag.   The code of the program...JSTL for Loop <c: forEach>     

Java Beginners

hi .. need help ASAP ..i have a project buit in eclipse , i have installed jasper. i want the steps to work on it ..
hi .. need help ASAP ..i have a project buit in eclipse , i have installed jasper. i want the steps to work on it ..   hi .. need help ASAP ..i have a project buit in eclipse , i have installed jasper. i want the steps to work 

JSP Servlet Questions

i want to pass Javascript value to JSP scriptlet..
i want to pass Javascript value to JSP scriptlet..  i am having a problem that, i am having a combo box in the JSP page when i select an item from... now i want to pass this value to JSP scriptlet 

Development process Questions

How can i implement the calculator programe in jsp code
How can i implement the calculator programe in jsp code  Please send code for the calculator using jsp technologies please guidelines to me.   Here is a simple jsp calculator code that accepts two numbers from the user 

JSP Servlet Questions

I want design samples for JSP project
I want design samples for JSP project  Sir, I world Like to do a project in jsp techonology. But i have no idea of selecting the project, especially if i selected any project i have no idea that is how to build ie how to design 

JSP Servlet Questions

i want to store dynamic number of value on one jsp and retrieve them on other.
i want to store dynamic number of value on one jsp and retrieve them on other.  in my problem, i want to run a query from database.then while in loop... are being created in result loop. i.e while(rs.next){}. i want to store 

JSP Servlet Questions

JSP Code - JSP-Servlet
JSP Code  Hi, I have a problem in limiting the number of row display in the table. For example, if i have 1000 records in my table & want to display only 10 records per pages in jsp, then how can i achieve this concept 

Programming Tutorials

Use if statement with LOOP statement
Use if statement with LOOP statement   ... with Example The Tutorial illustrate a example from if statement with LOOP.... The if and else is used to execute the code if the condition is true or the condition 

Ajax Questions

using ajax i want to insert data into oracle database
using ajax i want to insert data into oracle database  i would like to insert/update/select/delete from jsp to oracle database using ajax? please send a code for this iam using oracl database thank you 

General

JavaScript array for loop
JavaScript array for loop       In this Tutorial we want to understand you how an array for loop is executed in a JavaScript. The code import the following packages- 1 

Java Beginners

reg : the want of source code
reg : the want of source code  Front End -JAVA Back End - MS Access Hello Sir, I want College Student Admission Project in Java with Source code...) Available Seats and etc. plz Give Me Full Source code with Database 

General

JavaScript loop through
JavaScript loop through       In this Tutorial we want to describe you a code that help you... comparing  variable i and variable j in the loop and print the output as per condition 

PHP Questions

Jquery form validation does not work
Jquery form validation does not work  I want to use jquery validation for my Forms tags. I also imported necessary javascript files e.g. jquery.validate.min.js I called the functions (validate function) properly. But jquery 

PHP Questions

Jquery form validation does not work
Jquery form validation does not work  I want to use jquery validation for my Forms tags. I also imported necessary javascript files e.g. jquery.validate.min.js I called the functions (validate function) properly. But jquery 

Ajax Questions

loop error - Ajax
solution... i give the code...just like...    ..., as i mention.. after giving my code the out put shows.... 1 2 3 4 5 . . . . . . . infinity... but i want 

JSP Servlet Questions

how can i use one dbase conection in serveral pages - JSP-Servlet
how can i use one dbase conection in serveral pages  Hi! Thanks for sending code... But my actual requirement is In my project i am writing dbase... this....that means i want to write only one time and i want to call that in other pages 

Java Beginners

NoughtsAndCrossesGame play button doesn't work
NoughtsAndCrossesGame play button doesn't work   /* * To change... main(String[] args) { // TODO code application logic here...); // Create the buttons and add them to the JFrame for (int i = 0; i < 9; i 

Java Beginners

NoughtsAndCrossesGame play button doesn't work
NoughtsAndCrossesGame play button doesn't work   /* * To change... main(String[] args) { // TODO code application logic here...); // Create the buttons and add them to the JFrame for (int i = 0; i < 9; i 

PHP Questions

for( ) loop in php
for( ) loop in php  Generally, when we use for loop in PHP or any other programming language why we use i++ and not ++i. What is the reason behind 

PHP Questions

for( ) loop in php
for( ) loop in php  Generally, when we use for loop in PHP or any other programming language why we use i++ and not ++i. What is the reason behind 

PHP Tutorial

PHP Do While Loop
the code within. We generally use Do-While loop  when the iteration must run... of the variable within the loop. PHP do while loop Example: <?php $i=34; do... of $i is not valid but do-while loop runs at least one time despite 

JSP Servlet Questions

jsp code
jsp code  i want health management system project code using jsp.its urgent 

SQL Question

how do i use sql like query in my jsp page
how do i use sql like query in my jsp page  how do i use sql like query in my jsp page   Hi Friend, Try the following code: <%@ page...;br>"); } %> The above code will display all the names from the database 

HTML5

HTML5 audio loop, Use of loop attribute of audio tag in  HTML5.
HTML5 audio loop, Use of loop attribute of audio tag in  HTML5. Introduction:Loop attribute is used for reputation of audio or music. It repeats...; Example of  loop attribute in HTML5: Code: AudioLoop.html < 

JavaScript Questions

How I get a variable from java script to use it in the scriptlet of jsp.
How I get a variable from java script to use it in the scriptlet of jsp.  Hi i want to get the tinyUrl value in the scriptlet of jsp. // Bit.ly API var url="http://cplive.com/dealDetail.do?method=displayDealDetail& 

Ajax Questions

i want horizontal mlm tree structure code in php with jquery or Ajax
i want horizontal mlm tree structure code in php with jquery or Ajax  i need horizontal mlm tree structure code in php with jquery or Ajax... in advance.. Thank you 

Java Beginners

Hi i want java code that diaplays server scren at the client side
Hi i want java code that diaplays server scren at the client side  Hi I'm Shivaprasad i want java socket code that shows the server side screen when client gets connected with the server. Please help me   Please visit 

XML Questions

i want java code for this xml file...please show me..
i want java code for this xml file...please show me..   xbrli:shares xbrli:pure iso4217:INR 

Java Beginners

For loop
For loop  Hi! Please explain the following loop: for(i=0;i<a[j];i++) THANX!!   Please reply as soon as possible 

JDBC Questions

prepared statement in for loop - JDBC
prepared statement in for loop  Hi all, I am reding data from a jsp page and inserting into a table. For this i am using prepared statement in a for loop. But my problem is that only one row is getting inserted 

Java Magazine Questions

loop problem - Java Magazine
to main menu to select new item. //what loop to use? break; } } }  Hi Friend, Do you want to connect your...loop problem  import java.util.Scanner; class mychoice{ public 

JavaScript Questions

How to write a loop and a while loop
How to write a loop and a while loop  How do I write a 1 loop and a 1 while loop for the example code: public boolean isTheFirstOneBigger (int num1, int num2) { if (num1 > num2) { return true 

JSP Servlet Questions

JSP CODE
JSP CODE  Please help me as soon as possible.Its Urgent. I am working on my college ALUMNI PORTAL. I want to have a ADD FRIEND option in a user's profile. Please send me code 

Date Calendar

i want to create dynamic calendar in java
i want to create dynamic calendar in java  i want code and explanation 

Date Calendar

i want to create dynamic calendar in java
i want to create dynamic calendar in java  i want code and explanation 

JSP Servlet Questions

code - JSP-Servlet
code  i have one check box in my form. When i click the check box i want to execute some sql query.so i write one javascript function. but i dont...; use some server side script like servlet or jsp, call these when user click 

Java Beginners

This code send email two times but i want only once
This code send email two times but i want only once   public void dbbackup_notify(String email,String data,String subject){ String toEmails = email; Session session=Session.getInstance(props, new 

Java Beginners

This code send email two times but i want only once
This code send email two times but i want only once   public void dbbackup_notify(String email,String data,String subject){ String toEmails = email; Session session=Session.getInstance(props, new 

JSP Servlet Questions

jsp code
jsp code  i want to jsp code which are working as,i have three drop... and next one submit button,,,when i am clik on submit button data is show according to selectde menu,,,,please send me such type code,,,,plz help me 

Development process Questions

Want Automatic No with Date - Development process
Want Automatic No with Date   Hi, I want the jsp code. i want serial no with date and month.For example "240501" date is 24 and month is 05 and serial no 01 .Thanks Prakash 

PHP Questions

For Loop/PHP
12345. How would you write this as a loop? Would I need to use the for loop or do/while loop?   PHP Factorial Example: <?php $n = 5; $i = 1; $f...For Loop/PHP  Write a class called math. It is to have one property 

Java Beginners

For Loop
For Loop  Write a program using a for loop that computes... the user enters. This is an example of my upcoming quiz. I need help on knowing... + 4/2 + 5/2 + ... N/2 for(int i=1;i<=n;i++){ sum+=i 

Development process Questions

i want to display where i entered values to same page
i want to display where i entered values to same page  hi friends !! i have a values from jsp page .and i want to store that values into DB at the same time i want to show immediatlly on same jsp page with tabular format 

Development process Questions

i want to display where i entered values to same page
i want to display where i entered values to same page  hi friends !! i have a values from jsp page .and i want to store that values into DB at the same time i want to show immediatlly on same jsp page with tabular format 

Java Tips and Examples

for loop in java example
in the for term. We use three steps in for loop statement, these are: initialization... .style1 { color: #0000FF; } for loop in java example We are going to discuss about for loop in java example. The for loop statement has type 

Java Beginners

Updating variables in a loop? and only printing certain messages after the first iteration?!
. The reason why I want to do this is so I can use it to work out some calculations...Updating variables in a loop? and only printing certain messages after the first iteration?!  I've written a program that reads two values. I 

Apache Velocity

How to use foreach loop in velocity
How to use foreach loop in velocity       This Example shows you how to use foreach loop... in $list): This works like for loop in java but it has some enhanced functionality 

JSP Servlet Questions

want a project
want a project  i want to make project in java on railway reservation using applets and servlets and ms access as database..please provide me code and how i can compile and run 

PHP Questions

i want 2 columns to be deleted in mysql
i want 2 columns to be deleted in mysql  i want 2 columns to be deleted in mysql The tables having the columns have no mapping   Use the given query: ALTER TABLE table_name DROP col_name 

JavaMail Questions

I want complete tutorial on advanced java
I want complete tutorial on advanced java  I am studying advanced java like servlets, JSP's RMI EJB's JDBC & all stuff like this i want some tutorial file so that i can download it & read can anyone help me?    

Java Beginners

for loop
for loop  using only two for loop how can print below numbers 1...){ for(int i=1;i<=9;i++){ for(int j=1;j<=i;j++){ System.out.print(i); } System.out.println 

Java Beginners

for loop
for loop  using only two for loop how can print below numbers 1...){ for(int i=1;i<=9;i++){ for(int j=1;j<=i;j++){ System.out.print(i); } System.out.println 

JSP Servlet Questions

Code
Code  how to print this?? with the use of only JSP....... 1 23 456 78910   Here is the jsp number pattern example: 1 2 3 4 5 6 7 8 9 10 <%@page language="java"%> <% int k = 1; for(int i=1; i<= 4 ;i 

Java Beginners

for loop
for loop  hai, I need to write java program to print numbers in "X" format 

JSP Servlet Questions

code in jsp
code in jsp  hi.. I had started a project on college admission system... operator who can enter all the details of the student, can edit the forms...now i want a code to sort a list of students on the basis of there 12% marks and AIEEE 

Java Beginners

adding loop
adding loop  Hi I have a program that is not compiling when I add a loop can you help me?The program below is compiling without the loop. >...; class HardwareItems { String code; String description; double price 

Java Beginners

How does the Java for each loop work?
How does the Java for each loop work?  How does the Java for each loop work 

JSP Servlet Questions

i can not connect to database in servlet - JSP-Servlet
tested HelloWorld sample code and it was ok,but the tutorials which use database does not work. I have checked the database and it is running while i am running the code .My databse is Mysql 5.0 . I would be pleased by any insight you may 

JSP Servlet Questions

i can not connect to database in servlet - JSP-Servlet
tested HelloWorld sample code and it was ok,but the tutorials which use database does not work. I have checked the database and it is running while i am running the code .My databse is Mysql 5.0 . I would be pleased by any insight you may 

JSP Servlet Questions

jsp code - JSP-Servlet
jsp code  in my table there are 3 fields named orderid ,itemname, itemqty. i want code that fetch orderid in dropdown... on select dropdown get table of item details of that orderid... there are multiple items at one orderid 

JRuby

For Loop example in JRuby
print "Use of for loop in JRuby \n"   for i in 1..10  .... In this example we will show you how to use For-loop in JRuby. In this example we are showing you how to use for loop in JRuby. In Ruby "for-loop" 

JSP Tutorials

How to work with POST method in jsp page
How to work with POST method in jsp page       This is detailed JSP code, how to use... this code with extension .jsp in your application directory ("user" 

JSP Servlet Questions

I Want to take mqsyl batabase backup using jsp
I Want to take mqsyl batabase backup using jsp   I was develop web portal using jsp and servelt. I need to take backup my MySQL database and restore another one MySQL database.   import java.util.*; import java.io. 

Advertisements Advertisements
 

 

 

DMCA.com