| View previous topic :: View next topic |
| Author |
Message |
luigico889
Joined: 25 Aug 2009 Posts: 8 Location: Philippines
|
Posted: Wed Aug 26, 2009 6:24 am Post subject: How to save a PDF file in mobile phone |
|
|
Hi.
I have a jsp file that opens a PDF file.
Code:
<%@ page import="java.io.*" %>
<%@ page import="java.io.InputStream.*" %>
<%@ page import="java.net.*" %>
<%@page contentType="application/pdf" %>
<%
OutputStream o = response.getOutputStream();
URL u = new URL("http://localhost:8080/list_0809_3rd_term.pdf");
InputStream is =
u.openStream();
byte[] buf = new byte[32 * 1024]; // 32k buffer
int nRead = 0;
while( (nRead=is.read(buf)) != -1 ) {
o.write(buf, 0, nRead);
}
o.flush();
o.close();
%>
Is there a way to get the pdf from the jsp file and save it in mobile phone probably using Http Connection??
Need help badly, thanks |
|
| Back to top |
|
 |
Karol Harezlak Posted via mailing list.
|
Posted: Wed Aug 26, 2009 7:32 am Post subject: How to save a PDF file in mobile phone |
|
|
Hi,
It depends on capability of web browser. If your target browser allows
to to download and save files then you can do it. There is no direct
connection between your mobile browser/client and JSP pages. JSP
pages are compiled on the server side so you don't have direct access to
them.
K.
luigico889 wrote:
| Quote: | Hi.
I have a jsp file that opens a PDF file.
Code:
<%@ page import="java.io.*" %>
<%@ page import="java.io.InputStream.*" %>
<%@ page import="java.net.*" %>
<%@page contentType="application/pdf" %>
<%
OutputStream o = response.getOutputStream();
URL u = new URL("http://localhost:8080/list_0809_3rd_term.pdf");
InputStream is =
u.openStream();
byte[] buf = new byte[32 * 1024]; // 32k buffer
int nRead = 0;
while( (nRead=is.read(buf)) != -1 ) {
o.write(buf, 0, nRead);
}
o.flush();
o.close();
%>
Is there a way to get the pdf from the jsp file and save it in mobile phone probably using Http Connection??
Need help badly, thanks
|
--
Karol Harezlak <address-removed>
Sun Microsystems, Inc. NetBeans Mobilty/JavaFX |
|
| Back to top |
|
 |
luigico889
Joined: 25 Aug 2009 Posts: 8 Location: Philippines
|
Posted: Wed Aug 26, 2009 8:13 am Post subject: |
|
|
But arent there any other way to download a file from a local web server (localhost)? Coz we need to make a j2me midlet thats like a bookstore and downloads pdf books to a phone without viewing it. Any advice?
thanks again |
|
| Back to top |
|
 |
Karol Harezlak Posted via mailing list.
|
Posted: Wed Aug 26, 2009 8:23 am Post subject: How to save a PDF file in mobile phone |
|
|
Downloading file over HTTP it's easy. Look at the HTTP API and input
stream. This is one of the example but I did not check it if it works.
http://www.java-samples.com/showtutorial.php?tutorialid=15
K.
luigico889 wrote:
| Quote: | But arent there any other way to download a file from a local web server (localhost)? Coz we need to make a j2me midlet thats like a bookstore and downloads pdf books to a phone without viewing it. Any advice?
thanks again
|
--
Karol Harezlak <address-removed>
Sun Microsystems, Inc. NetBeans Mobilty/JavaFX |
|
| Back to top |
|
 |
luigico889
Joined: 25 Aug 2009 Posts: 8 Location: Philippines
|
Posted: Wed Aug 26, 2009 8:50 am Post subject: |
|
|
| ok ill check it out. thanks!! |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|
|
|