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 7761783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:13:31+00:00 2026-06-01T14:13:31+00:00

I need to implement a call to a method that I have in my

  • 0

I need to implement a call to a method that I have in my controller. But I want to call this method from a scriptlet and I don’t know how to do it. I am trying to export data that I get from the server to CSV.

This is the scriptlet that I have so far:

<%  
String csvDataIn = request.getParameter("exportCSVParam");
String csvFileName = request.getParameter("exportCSVFileName");
if (csvFileName == null || csvFileName == "") csvFileName = "export.csv";

String strHeader = "attachment; filename=" + csvFileName;
String contentType = "application/octet-stream";
response.setContentType(contentType);
response.addHeader("content-disposition",strHeader);

ServletOutputStream ostr = response.getOutputStream();    
String data=csvDataIn;//DATA GOES HERE;
ostr.write(data.getBytes("ISO-8859-1"));
ostr.flush();
ostr.close();
%>

Assume that I want to call a method getDataAsCsv() that I have in my controller that returns a String with the CSV data that I want to print in that file. Lines 1 and 2 (csvDataIn, csvFileName) should be deleted since I am not going to send parameters to this jsp. How do you do that?. How do you bind the controller bean with this scriptlet.

I am new to spring and I am still learning about this. Probably the solution is very simple but I am stuck with this.

  • 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-01T14:13:32+00:00Added an answer on June 1, 2026 at 2:13 pm

    You can’t, because you shouldn’t. All this code should go in the controller.

    (technically, you can have a JSTL function and call it, or simply call a static method, or even get the controller with WebApplicationContextUtils.getRequiredWebApplicationContext(..).getBean(..), but all these will be ugly)

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

Sidebar

Related Questions

I have this method that I need to call and use in my application,
I know I can create a generic method that I can call from other
I have three classes that implement an interface and I need one Method that
Let's suppose I have an interface named Controller. Several classes implement this interface and
I have recently come across a problem trying to implement Model-View-Controller in Swing .
I need to implement a custom handler for MVC that gives me the first
I need to implement handling of redelivery of JMS messages in the application that
I can't seem to find a method to call different controller in the same
I have two webservices that have exactly the same methods and signatures but point
I have a recursive method call. When any exception is thrown, I would like

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.