Support the ongoing development of Laravel.io →
Installation Views Architecture
Last updated 2 years ago.
0

Just use servelets and jsp, why bother with laravel?

0

Because the user needs to download a xlsm file.

How can I use servelets and jsp?

This is my first time I'm trying to implement this.

0

lol, you need to set header to the correct content type. Just look for the correct content type of xlsm

Something like,

...
HttpServletResponse response = (HttpServletResponse)response;
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition", "attachment;filename=yourfile.csv");
...
0

I think you do not understand my question.

In one of my laravel view I have a button which I would like to request java code.

This is my view:

<div class="widget widget-body text-center">
  <div class="row">
    {{ Form::open(array('action' => array('ProcessController@requestXlsm', $process->process),'method' => 'post')) }}
      <div class="innerAll">
        {{ Form::button('Request xlsm file', array('class' => 'primary btn btn-primary btn-stroke')) }}
      </div>
    {{ Form::close() }}          
  </div>  
</div>

From here, how can I use servlets and jsp?

Thank you

Last updated 9 years ago.
0

Oh my god. Your original message was misleading. The above code works purely in Java, not PHP. If that's the case, you do not need servlets and jsp. I assume you already know what they are and they do, so I am not going to explain to much detail. Basically they are 2 different languages. Now, to do it in Laravel, it is recommended you go thru these links first to see they can help you.

At the section, Creating A File Download Response

http://laravel.com/docs/5.0/responses

HTTP Headers

http://en.wikipedia.org/wiki/List_of_HTTP_header_fields

Similar to the Java code, you will still need to send header the correct content type to server to response because this is how HTTP works.

Hope they help.

PS: Just curious, how does xlsm file related to your Java classes? :D

Last updated 9 years ago.
0

Well sorry @awsp but my english is bad and sometimes i can't explain what I want. By topic will be much easy to understand the procedure that I want.

1º) My user want to requests a download of xlsm file (from Laravel).

2º) I need to read the xlsm file.

3º) I need to write the xlsm file that I read. The data comes from the mysql database.

4º) After writing the xlsm file, automtically download the file.

This is what i'm thinking to do.

I able to read and write the xlsm file in java. I do not in PHP because of file macros xlsm.

So I would like to know the best way to do that?

My problem here is to connect PHP to java. ( I think it is but maybe I'm wrong).

Thank you

0

Seems like a hard task to do if you need to retain the macros inside the XLS file. There seems not too many libraries in PHP doing this.

I would recommend do it plain in Java. Tho, a dump way (if you must use Laravel/PHP), just do whatever you need to do with Laravel, login, post form, and make a request to a JSP/Servlet and ask Tomcat / GlassFish server (whichever you are using) to read and write the XLSM file and generate an URL back to PHP, then CURL to download that file using PHP.

http://stackoverflow.com/questions/22155882/php-curl-download-file

http://stackoverflow.com/questions/14149856/force-to-download-a-remote-file-via-curl-or-other-method

A very dump way, tho, doesn't look logical to me. But I couldn't think of any better way to do in PHP. :(

Last updated 9 years ago.
0

I need always Tomcat/GlassFish?

My laravel website is installing on linux server and I don't have Tomcat/Glassfish server available on my linux server.

0

One question...you have mentioned you are able to read/write XLSM file using Java so I assume you are using J2EE? Or by any chance, I misunderstood again? lol

You can install Apache Tomcat on any servers, Java can be run in all environment.

So basically you are running (at least) 2 different servers, one for PHP (mostly like Apache2 Web Server), and one for Java (can be either Apache Tomcat or GlassFish).

Deploy your J2EE application to Tomcat on a different port than 80, and run Laravel on Apache2 at port 80.

###TL;DR Lastly, some of my thoughts, indeed, like @jimgwhit said, why bother to use Laravel if you can build your site using J2EE entirely? You know Java can be used to build website too! :D

Last updated 9 years ago.
0

I read and write xlsm file on my computer, I just create a java application.

My laravel is installed on my linux server but can't have option to install Tomcat.

Basically I don't know how can i solved this. I'm lost.

0

If there was a way to preserve the macros in PHP, it would be much easier.

I searched for multiple option included PHPEXCEL but nothing.

0

Ah, it seems like you are doing it using J2SE then.

Depends on your hosting, some will allow you do install Tomcat on your server. Or you could just grab one for $5 from Digital Ocean.

I believe code written in J2SE could be used in J2EE as well, basically J2EE just have more classes specifically targeting the Internet. Just write your XLSM file to a temporary folder and set HTTP header to download it. After like 15 minutes or so, simply delete that temp file from your file system.

To me, the most straight forward is to write a simple JSP/Servlet website instead of using Laravel.

Good Luck!

Last updated 9 years ago.
0

I saw on the Internet the xlsm file can be unzip. If I unziped the file maybe I can just write data into worksheets, zip the file and save with a new file.

Maybe I can avoid using java.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

jonitopsg jonitopsg Joined 18 Jun 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.