| | |
How Do I read in a file as text to a buffer?
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
You can use the
URLConnection class or the Apache Commons HttpClient library to retrieve the HTML generated by your JSP; pushing it into a StringBuffer/StringBuilder is just a matter of reading the HTTP response stream. I don't accept change; I don't deserve to live.
Jo Tujhe Jagaaye, Nindein Teri Udaaye Khwaab Hai Sachcha Wahi.
Nindon Mein Jo Aaye Jise To Bhul Jaaye Khawab Woh Sachcha Nahi.
Khwaab Ko Raag De, Nind Ko Aag De
Jo Tujhe Jagaaye, Nindein Teri Udaaye Khwaab Hai Sachcha Wahi.
Nindon Mein Jo Aaye Jise To Bhul Jaaye Khawab Woh Sachcha Nahi.
Khwaab Ko Raag De, Nind Ko Aag De
•
•
Join Date: Aug 2007
Posts: 66
Reputation:
Solved Threads: 0
hey thanx for the response....check me out this what I got:
I got a form called "homeSellerReport1.jsp"..that has a submit that goes to this page:
but im getting this error
java.io.IOException: Server returned HTTP response code: 500 for URL: http://localhost:8080/JAABA/jsp/cpan...lerReport1.jsp
I got a form called "homeSellerReport1.jsp"..that has a submit that goes to this page:
Java Syntax (Toggle Plain Text)
<%@ page language="java" %> <%@ page import="trader.webservices.util.Utils" %> <%@ page import="trader.webservices.util.EmailSender" %> <%@ page import="trader.webservices.data.UserDataVO" %> <%@ page import="trader.webservices.data.UserInfoDAO" %> <%@ page import="trader.webservices.data.AgentInfoDAO" %> <%@ page import="java.io.DataOutputStream" %> <%@ page import="java.io.FileOutputStream" %> <%@ page import="java.io.FileInputStream" %> <%@ page import="java.io.IOException" %> <%@ page import="java.util.*" %> <%@ page import="java.net.*" %> <%@ page import="java.io.*" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <% UserDataVO userData = null; String username = request.getParameter("username"); String password = request.getParameter("password"); String format = "txt"; //String domainName = UserInfoDAO.removeHostRedirection(request.getServerName()); String adminServer = request.getServerName(); String javaAdminServer = request.getServerName(); if (request.getServerName().equals("localhost") || request.getServerName().startsWith("199")) { adminServer = "cpanel.homes.com"; javaAdminServer = "localhost:8080"; } userData = UserInfoDAO.getUserInfo(username); //String address = "suggestaservice@agentadvantage.com,support@agentadvantage.com"; String emailTo = request.getParameter("emailTo"); URL httpUrl = new URL("http://" + javaAdminServer + "/JAABA/jsp/cpanel/homeSellerReport1.jsp"); InputStream fis = httpUrl.openStream(); byte[] bytes = new byte[fis.available()]; fis.read(bytes); String strFileContent = new String(bytes); String msgBody = "Attached is the homeseller report you requested."; EmailSender emailSender = new EmailSender(); emailSender.sendMailWithAttachment(emailTo,"web@homes.com","HomeSeller Report from Control Pane, Test",msgBody,strFileContent,format); %>
but im getting this error
java.io.IOException: Server returned HTTP response code: 500 for URL: http://localhost:8080/JAABA/jsp/cpan...lerReport1.jsp
Last edited by mimsc; Jul 22nd, 2009 at 3:02 pm.
Is that link accessible via the browser? Since a server error has occurred, it might pay off to see the server log for more details.
BTW, I think you are better off using a free reporting tool like Jasper Reports to create reports rather than use the JSP of your very own application. Also, moving all this business code in a separate class which would be called by the servlet would be a wise move.
BTW, I think you are better off using a free reporting tool like Jasper Reports to create reports rather than use the JSP of your very own application. Also, moving all this business code in a separate class which would be called by the servlet would be a wise move.
I don't accept change; I don't deserve to live.
Jo Tujhe Jagaaye, Nindein Teri Udaaye Khwaab Hai Sachcha Wahi.
Nindon Mein Jo Aaye Jise To Bhul Jaaye Khawab Woh Sachcha Nahi.
Khwaab Ko Raag De, Nind Ko Aag De
Jo Tujhe Jagaaye, Nindein Teri Udaaye Khwaab Hai Sachcha Wahi.
Nindon Mein Jo Aaye Jise To Bhul Jaaye Khawab Woh Sachcha Nahi.
Khwaab Ko Raag De, Nind Ko Aag De
•
•
Join Date: Aug 2007
Posts: 66
Reputation:
Solved Threads: 0
•
•
•
•
Is that link accessible via the browser? Since a server error has occurred, it might pay off to see the server log for more details.
BTW, I think you are better off using a free reporting tool like Jasper Reports to create reports rather than use the JSP of your very own application. Also, moving all this business code in a separate class which would be called by the servlet would be a wise move.
nah that link is not accesible via the browser...the log's tellin me Im getting a null from that page im trying to read from because its a form that requires parameters passed to it once accessed.....so I know what the problem is.....I just dont know how to get around it
> a form that requires parameters passed to it once accessed.....so I
> know what the problem is.....I just dont know how to get around it
You can pass those form parameters in the URL [assuming you know what they are]
But like I previously mentioned, all this is really hackish; you really need to come up with something better than calling your own JSP and mailing its response.
> know what the problem is.....I just dont know how to get around it
You can pass those form parameters in the URL [assuming you know what they are]
Java Syntax (Toggle Plain Text)
String url = "http://localhost/MyApp/param1=value1¶m2=value2";
But like I previously mentioned, all this is really hackish; you really need to come up with something better than calling your own JSP and mailing its response.
Last edited by ~s.o.s~; Jul 22nd, 2009 at 4:35 pm.
I don't accept change; I don't deserve to live.
Jo Tujhe Jagaaye, Nindein Teri Udaaye Khwaab Hai Sachcha Wahi.
Nindon Mein Jo Aaye Jise To Bhul Jaaye Khawab Woh Sachcha Nahi.
Khwaab Ko Raag De, Nind Ko Aag De
Jo Tujhe Jagaaye, Nindein Teri Udaaye Khwaab Hai Sachcha Wahi.
Nindon Mein Jo Aaye Jise To Bhul Jaaye Khawab Woh Sachcha Nahi.
Khwaab Ko Raag De, Nind Ko Aag De
![]() |
Similar Threads
- how do read last file (C)
- Read from file, delimiter is ; (C++)
- write and read to file (C++)
- Custom Class - File I/O (C++)
- how to read a file from client side without browsing (ASP.NET)
- C++ How can read from file.txt & where can save this file(file.txt) to start reading (C++)
- create, write & read file to/from folder (C++)
- Read in a file and store in char array (C)
Other Threads in the Java Forum
- Previous Thread: Java Encryption and Decryption
- Next Thread: GUI plug-in for eclips
| Thread Tools | Search this Thread |
Tag cloud for Java
@param add android api apple applet application arguments array arrays automation bank binary binarytree bluetooth bold chat chatprogramusingobjects class classes client code compare component coordinates database digit draw eclipse editor error event exception fractal game givemetehcodez graphics gui guidancer health html ide image input int integer integration j2me jarfile java javac javame javaprojects jmf jni jpanel julia keytool learningresources linux list loop map method methods mobile netbeans newbie nonstatic number oracle pattern print problem program programming project projectideas recursion scanner screen server set sharepoint size sms socket sort sorting sql sqlserver string swing test text-file threads time tree web windows






