Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9015815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:50:38+00:00 2026-06-16T03:50:38+00:00

I am using struts to develop my web application. I wrote a method which

  • 0

I am using struts to develop my web application. I wrote a method which generates excel file and saves it based on the data model I pass.. Works great on my local machine since tomcat is present locally.. But now I’ve moved my application to a central server.. Now if I use the method it stores generates the excel file in the server not in the client machine which are hitting the server.. I need to pass it from server to client through http.. How do I do that?

public static void populateExcelDoc(List<ColumnList> listOfColumns,RowList rowlist,String filename)
{
    try
    {
        WorkbookSettings ws = new WorkbookSettings();
        ws.setLocale(new Locale("en", "EN"));

        WritableWorkbook workbook = Workbook.createWorkbook(new File(filename+".xls"), ws);
        WritableSheet s = workbook.createSheet("Sheet1", 1);
        writeDataSheetifx1(s,listOfColumns,rowlist);
        workbook.write();
        workbook.close();

        Process p = 
                  Runtime.getRuntime()
                   .exec("rundll32 url.dll,FileProtocolHandler " + filename+".xls");
    }
    catch(IOException e)
    {
        e.printStackTrace();
    }
    catch(WriteException e)
    {
        e.printStackTrace();
    }
}  

This is what my current code looks like.. What change do I need to make? Should I be using HttpServletResponse response?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T03:50:40+00:00Added an answer on June 16, 2026 at 3:50 am

    In Struts2 there is stream result for sending data to the HttpServletResponse.

    In your struts.xml configure your action to use stream result.

    <action name="exceldoc" method="populateExcelDoc" class="ExcelDocAction">
      <result name="success" type="stream">
        <param name="inputName">inputStream</param>
        <param name="contentType">application/vnd.ms-excel</param>
        <param name="contentDisposition">attachment;filename=excel.xls</param>
      </result>
    </action>
    

    And inside your action create private InputStream inputStream; with getters/setters and write your file to it inside your method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using struts, I have a java web application which needs to run
I have developed a web based application using STRUTS 2.0 and I want to
I am using eclipse to develop a web application. Just today I have updated
i am using mvc struts framework in my web application. i am displaying dynamic
I have a web application that using Struts + Spring + Hibernate . In
I develop an application using Struts, Spring, and Hibernate. My DAOs uses spring jdbc
I'm using Struts 1.3.10 in a web application, and I want my textfields to
I am using Struts and Hibernate for my web application. And also i have
This is for a web application using struts. I have an array of objects
I want to develop a web-application with a fileupload mechanism using struts2 with fileUpload

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.