且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在jsp中获取java控制台输出

更新时间:2022-11-30 19:47:07

为了在jsp页面中显示输出,你必须使用out.write( ); method.so,在for循环中使用

 out.write(< input type =radio>+ work +< br>); 


am using forloop for getnumbersheets in excel file in javaclass.how can i display sheetnames in jsp with radiobutton for all sheets

What I have tried:

package com;

import java.io.FileInputStream;

import java.io.IOException;
import java.util.ArrayList;

import org.apache.poi.xssf.usermodel.XSSFWorkbook;

public class ExcelDataParser
{
private ArrayList<string>arr;

public ArrayList<string> getArr() {
return arr;
}

public void setArr(ArrayList<string> arr) {
this.arr = arr;
}
//public static void getSheetNames()
public static void main(String args[]) throws IOException
{
ArrayList<string> arr=new ArrayList<string>();

try {
String str="C:\\Downloads\\Associate_Details.xlsx";

FileInputStream fileInputStream = null;

fileInputStream = new FileInputStream(str);
XSSFWorkbook workbook = new XSSFWorkbook(fileInputStream);
String work;
for (int i = 0; i < workbook.getNumberOfSheets(); i++)
{

work=workbook.getSheetName(i);
arr.add(work);
}
System.out.println(arr);
workbook.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}}

}

In order to show the output in jsp page you have to use out.write(); method.so, inside your for loop use
out.write("<input type="radio">"+work+"<br>");