Cached input stream?
the problem i got is that i got a lot of processes reading the same amount of bytes (6k) from disk at the same time. this will lead to the point where the IO starts blocking since it has to serve too much at once. a solution would be rading out larger chunks at once (like 100k) using something like a CachedImputStream. the CachedInputStream could be chained with a normal InputStream that reads the 6k out of it. this way the disks searches could be reduced a lot.
i was wondering if there is something like a cached input stream for java already or if i have to wirte one by myself? (note: a BufferedInputStream wouldn't solve the problem since it only tries to keep the buffer full in memory - i can't specify how many bytes to read from disk at once)
i can't specify how many bytes to read from disk at onceDo you mean the following method does not work?
read(byte[] bytes, int start, int length)?
You will probibly find that the OS reads a fixed size e.g. 8K, 16K, 32K or 64K depending on the block size of the disk regardles sof what you set. Using this option reduced the number of calls from your program to the OS, how the OS accesses the disk cannot be controlled in Java. (Your program can only provide a hint)
If performance is an issue, either reduce the number of concurrent requests or use higher performing disks such as SCSI or multiple SCSI drives mirrored/stripped.
Similar Messages
-
SocketException during reads - JVM_recv in socket input stream read
I am getting a SocketException when a Java applet talks to our
WebLogic 7.0 server. The catch is that it only occurs at one site
(that has very high T1 utilization, although latency is only ~60 ms)
Our setup is such that the calls hit an Alteon load balancer, which
then sends the request out to one of 4 IIS clustered servers, where it
then is sent to one of 2 WL clustered servers. I figured latency
would be the cause, but on IIS and on WL, the timeouts are set to
several hundred seconds, so I am not quite seeing where the connection
is being reset. To be honest, I really don't know if it is WL that is
killing the connection, as nothing abnormal shows up in the WL log. I
have seen similar problems in this group, though, although the stack
traces never follow the same path mine does. I do have the following
call stack from the Java plug-in console, though. Any ideas would be
greatly appreciated.
java.net.SocketException: Connection reset by peer: JVM_recv in socket
input stream read
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(Unknown Source)
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read1(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
at sun.net.www.http.HttpClient.parseHTTPHeader(Unknown Source)
at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown
Source)
at sun.plugin.net.protocol.http.HttpURLConnection.getInputStream(Unknown
Source)
at sun.net.www.protocol.http.HttpURLConnection.getHeaderFields(Unknown
Source)
at sun.plugin.net.protocol.http.HttpURLConnection.checkCookieHeader(Unknown
Source)
at sun.plugin.net.protocol.http.HttpURLConnection.getInputStream(Unknown
Source)
at org.xxxx.abstracts.Controller.sendRequest(Controller.java:39)
at org.xxxx.data.DataMediator.getDataNode(DataMediator.java:46)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Also, here is my code, although I can't see anything on the client
side that seems off:
public Object sendRequest( Object request, URL receiver ) throws
Exception{
Object response = null;
URLConnection con = null;
ObjectOutputStream out = null;
ObjectInputStream in = null;
try {
con = receiver.openConnection();
con.setDoInput(true);
con.setDoOutput(true);
con.setUseCaches(false);
con.setDefaultUseCaches(false);
con.setAllowUserInteraction(false);
out = new ObjectOutputStream(con.getOutputStream());
out.writeObject(request);
out.flush();
out.close();
in = new ObjectInputStream(con.getInputStream());
response = in.readObject();
in.close();
} catch (ClassCastException e) {
if( out != null ){
out.close();
if( in != null ){
in.close();
} catch (Exception e) {
if( out != null ){
out.close();
if( in != null ){
in.close();
throw e;
return response;There is a known bug on earlier 1.3.1 releases with sockets on Windows 2k
and XP. I don't remember all the details.
Peace,
Cameron Purdy
Tangosol, Inc.
http://www.tangosol.com/coherence.jsp
Tangosol Coherence: Clustered Replicated Cache for Weblogic
"Keith Patrick" <[email protected]> wrote in message
news:[email protected]...
I'm getting the exception on the client, which is an XP machine, while
the server is Win2K. I can't recall which, but either the applet or
the server runs 1.3x while the other runs 1.4. I discounted that
factor, though, as the problem only occurs on one site, which on all
others it works fine.
"Cameron Purdy" <[email protected]> wrote in message
news:<[email protected]>...
Exception is in the applet or on the server?
Would one of those by any chance be running on W2K with JDK 131_01 orolder?
>>
Peace,
Cameron Purdy
Tangosol, Inc.
http://www.tangosol.com/coherence.jsp
Tangosol Coherence: Clustered Replicated Cache for Weblogic
"Keith Patrick" <[email protected]> wrote in message
news:[email protected]...
I am getting a SocketException when a Java applet talks to our
WebLogic 7.0 server. The catch is that it only occurs at one site
(that has very high T1 utilization, although latency is only ~60 ms)
Our setup is such that the calls hit an Alteon load balancer, which
then sends the request out to one of 4 IIS clustered servers, where it
then is sent to one of 2 WL clustered servers. I figured latency
would be the cause, but on IIS and on WL, the timeouts are set to
several hundred seconds, so I am not quite seeing where the connection
is being reset. To be honest, I really don't know if it is WL that is
killing the connection, as nothing abnormal shows up in the WL log. I
have seen similar problems in this group, though, although the stack
traces never follow the same path mine does. I do have the following
call stack from the Java plug-in console, though. Any ideas would be
greatly appreciated.
java.net.SocketException: Connection reset by peer: JVM_recv in socket
input stream read
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(Unknown Source)
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read1(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
at sun.net.www.http.HttpClient.parseHTTPHeader(Unknown Source)
at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown
Source)
at
sun.plugin.net.protocol.http.HttpURLConnection.getInputStream(Unknown
Source)
at sun.net.www.protocol.http.HttpURLConnection.getHeaderFields(Unknown
Source)
atsun.plugin.net.protocol.http.HttpURLConnection.checkCookieHeader(Unknown
Source)
atsun.plugin.net.protocol.http.HttpURLConnection.getInputStream(Unknown
Source)
at org.xxxx.abstracts.Controller.sendRequest(Controller.java:39)
at org.xxxx.data.DataMediator.getDataNode(DataMediator.java:46)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Also, here is my code, although I can't see anything on the client
side that seems off:
public Object sendRequest( Object request, URL receiver ) throws
Exception{
Object response = null;
URLConnection con = null;
ObjectOutputStream out = null;
ObjectInputStream in = null;
try {
con = receiver.openConnection();
con.setDoInput(true);
con.setDoOutput(true);
con.setUseCaches(false);
con.setDefaultUseCaches(false);
con.setAllowUserInteraction(false);
out = new ObjectOutputStream(con.getOutputStream());
out.writeObject(request);
out.flush();
out.close();
in = new ObjectInputStream(con.getInputStream());
response = in.readObject();
in.close();
} catch (ClassCastException e) {
if( out != null ){
out.close();
if( in != null ){
in.close();
} catch (Exception e) {
if( out != null ){
out.close();
if( in != null ){
in.close();
throw e;
return response; -
Problem reading input stream of urlconnection within portal
Hi,
This may be a generic server issue rather than portal but since it's my portal app that's displaying the problem I'll post it here.
Part of my Portal attempts to POST to a remote server to retrieve some search results.
In environments A & B (both standalone instances) this works fine.
In environment C this works on the managed instances in the cluster but not the admin instance.
In environment D (again standalone) it fails, but if I add a managed instance it works from the managed instance.
The problem I'm seeing is that I get a stuck thread and the thread dump shows it is blocked attempting to read the resulting input from a urlconnection. (Using a buffered input stream).
I've copied the code to a standalone class that runs fine from the same server(s). I've pasted this code below, the contents of the test() method were copied directly from my webapp (urls changed here for clarity).
Does anyone know of any securitymanager issues that may cause this?
Or anything else for that matter?
Code sample:
package src.samples;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
public class POSTTest {
public static boolean test()
URL url = null;
try {
url = new URL
("http://hostx:80/myapp/search.html");
catch (MalformedURLException e)
e.printStackTrace();
return false;
URLConnection urlConn;
DataOutputStream printout;
BufferedReader input;
urlConn = null;
try {
urlConn = url.openConnection();
catch (IOException e)
e.printStackTrace();
return false;
// Let the run-time system (RTS) know that we want input.
urlConn.setDoInput (true);
// Let the RTS know that we want to do output.
urlConn.setDoOutput (true);
// No caching, we want the real thing.
urlConn.setUseCaches (false);
// Specify the content type.
urlConn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
// Send POST output (this is a POST because we write then read as per the JDK Javadoc)
printout = null;
String body = "";
try {
System.out.println("url=" + url.toString());
printout = new DataOutputStream (urlConn.getOutputStream ());
String content = "param1=A¶m2=B¶m3=C¶m4=D¶m5=E";
System.out.println("urlParams= " + content);
printout.writeBytes (content);
System.out.println("written parameters");
printout.flush ();
System.out.println("flushed parameters");
printout.close ();
System.out.println("closed parameter stream");
// <b>Get response data - this is where it blocks indefinitely</b>
input = new BufferedReader(new InputStreamReader(urlConn.getInputStream()));
System.out.println("got input");
String str;
while (null != ((str = input.readLine()))) {
body = body + str + "\n";
System.out.println("read input:");
System.out.println(body);
input.close ();
System.out.println("closed input stream");
catch (IOException e) {
System.out.println("IOException caught: read failed");
e.printStackTrace();
return false;
return true;
* @param args
public static void main(String[] args) {
System.out.println("Test result= " + test());In your recuperar() method, read the FTP input stream into a byte array. (You can do that by copying it to a ByteArrayOutputStream and then getting the byte array from that object.) Then, return a ByteArrayInputStream based on those bytes. After you call completePendingCommand(), of course.
That's one way.
PC² -
How do I return an input stream from a text file
Suppose there's a class with methods..
one of the methods is something like..
public int value() and has a return statement at the end obviously for returning an int value..
Another method reads a text file and creates an input stream..
Scanner data = new Scanner(new File(input.next()));
I want to return the data when I do a call to this method, but I'm not sure what the method heading would look like..flounder wrote:
Are we supposed to magically know what those errors are? Do you think that copying and pasting the exact error messages and indicating the lines they occur on would be useful to us?Sorry about that..
I've replicated the same code below; and put the number of the line where the error is.
+cannot find symbol variable read [line 21]+
+cannot find symbol variable read [line 23]+
+cannot find symbol variable read [line 29]+
+cannot find symbol variable read [line 31]+
+cannot find symbol variable inputStream [line 44]+
+calculate() in textInput cannot be applied to (java.util.Scanner) [line 57]+
the reason I have the _______ for the createInputStream() method is because I'm not really sure what the heading type should be to return the input stream.
import java.io.*;
import java.util.*;
public class textInput
public void requestFileName()
Scanner input = new Scanner(System.in);
System.out.print("Enter file name: ");
public _______ createInputStream() throws FileNotFoundException
Scanner input = new Scanner(System.in);
Scanner read = new Scanner(new File(input.next()));
return read;
public void calculate() throws IOException
21 double max;
double min;
23 int count = 0;
double total = 0;
if (read.hasNextDouble())
double temp = read.nextDouble();
29 max = temp;
min = temp;
31 count++
total += temp;
while (read.hasNextDouble())
double current = read.nextDouble();
count++;
min = Math.min(current, min);
max = Math.max(current, max);
total += current;
System.out.println("Max of: " + max);
System.out.println("Min of: " + min);
44 System.out.println("Average of " + total/count);
public void close() throws IOException
inputStream.close();
public static void main(String[] args)
textInput run = new textInput();
try
57 run.requestFileName();
run.createInputStream();
run.calculate();
run.close();
catch(FileNotFoundException e)
System.out.println("File not found.");
System.exit(0);
catch(IOException e)
System.out.prinln("File not found.");
System.exit(0);
} -
When using URLConnection read input stream error
hi,
In my applet I build a URLConnection, it connect a jsp file. In my jsp file I refer to a javaBean. I send two objects of request and response in jsp to javaBean. In javabean return output stream to URLConnect. At that time a error happened.WHY???(Applet-JSP-JAVABean)
Thanks.
My main code:
APPLET:(TestApplet)
URL url = new URL("http://210.0.8.120/jsp/test.jsp";
URLConnection con;
con = url .openConnection();
con = servlet.openConnection();
con.setDoInput( true );
con.setDoOutput( true );
con.setUseCaches( false );
con.setRequestProperty( "Content-Type","text/plain" );
con.setAllowUserInteraction(false);
ObjectOutputStream out;
out = new ObjectOutputStream(con.getOutputStream());
Serializable[] data ={"test"};
out.writeObject( data );
out.flush();
out.close();
//until here are all rigth
ObjectInputStream in = new ObjectInputStream( con.getInputStream() );//happened error
JSP:
TestBean testBean = new TestBean ();
testBean .execute(request, response);
JAVABEAN:
public void execute( HttpServletRequest request,
HttpServletResponse response )
ObjectInputStream in = new ObjectInputStream( request.getInputStream() );
String direct = (String) in.readObject();
System.out.prinltn("direct");
ObjectOutputStream out = new ObjectOutputStream( response.getOutputStream() );
SerializableSerializable[] data ={"answer"};
out.writeObject( data );
out.flush();
out.close();
Error detail:
java.io.StreamCorruptedException: invalid stream header
at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:729)
at java.io.ObjectInputStream.<init>(ObjectInputStream.java:251)
at TestApplet.postObjects(TestApplet.java:172)you have to pay attention to the sequence of opening the streams.
The following example is: client sends a string to server, and servlet sends a response string back.
client side:
URL url = new URL( "http://152.8.113.149:8080/conn/servlet/test" );
URLConnection conn = url.openConnection();
System.out.println( "conn: " + conn );
conn.setDoOutput( true );
conn.setDoInput( true );
conn.setUseCaches( false );
conn.setDefaultUseCaches (false);
// send out a string
OutputStream out = conn.getOutputStream();
ObjectOutputStream oOut = new ObjectOutputStream( out );
oOut.writeObject( strSrc );
// receive a string
InputStream in = conn.getInputStream();
ObjectInputStream oIn = new ObjectInputStream( in );
String strDes = (String)oIn.readObject();server side
// open output stream
OutputStream out = res.getOutputStream();
ObjectOutputStream oOut = new ObjectOutputStream( out );
// open input stream and read from client
InputStream in = req.getInputStream();
ObjectInputStream oIn = new ObjectInputStream( in );
String s = (String)oIn.readObject();
System.out.println( s );
// write to client
oOut.writeObject( s + " back" ); I have the complete example at http://152.8.113.149/samples/app_servlet.html
don't forget to give me the duke dollars. -
Hi,
We are getting the following error when running our SSIS packages on Microsoft SQL Server 2012 R2 on Windows Server 2008 R2 SP1:
Error: 4014, Severity:20, State: 11. A fatal error occurred while reading the input stream from the network. The session will be terminated (input error: 109, output error: 0)
SQL Server Data Tools and SQL Server Database Engine reside on the same server.
We tried the following:
Disabling TCP Chimney Offload
Installed Windows Server 2008 SP1
Splitting our SSIS code into multiple steps so it is not all one large continuous operation
The error occurs during a BulkDataLoad task.
Other options we are investigating with the engineering team (out-sourced, so delayed responses):
Firewall configurations (everything is local, so this should not make a difference)
Disabling the anti-virus scanner
Are there other things we can try?
Any insight is greatly appreciated.
Thanks!Hi HenryKwan,
Based on the current information, the issue can be caused by many reasons. Please refer to the following tips:
Install the latest hotfix based on your SQL Server version. Ps: there is no SQL Server 2012 R2 version.
Change the MaxConcurrentExecutables property from -1 to another one based on the MAXDOP. For example, 8.
Set "RetainSameConnection" Property to FALSE on the all the connection managers.
Reference:
https://connect.microsoft.com/SQLServer/feedback/details/774370/ssis-packages-abort-with-unexpected-termination-message
If the issue is still existed, as Jakub suggested, please provide us more information about this issue.
Thanks,
Katherine Xiong
Katherine Xiong
TechNet Community Support -
Error in external tax system: SAX processing failed on input stream SAX pro
Hi
When I was posted in T.Code: FB70, (Customer Invoice) I am getting below mentioned error.
Error in external tax system: SAX processing failed on input stream SAX processi.
I put tick mark on calculate Tax column and select O1(A/R Sales Taxable).
Pls. help me.
Thanks
RanjithHi Ranjith,
I also face this problem in Production now.
Could you kindly share with me how you resolved this issue?
Thanks,
Markus -
ExecTask - java.io.EOFException: Unexpected end of ZLIB input stream
BOXI 3.1 FP 7 deployed on AIX environment with all the lang packs. Trying to install SP2 on AIX, when it comes to deploying the war files, AnalyticalReporting, the install encounters error. This error appears to be with size of the war file. Anyone came across this issue?
2010-03-30 10:10:00,633 Target - Target "expand_and_package" started.
2010-03-30 10:10:00,634 Delete - Deleting directory /export/home/Business_Objects/global/deployment/workdir/tomcat55/resources/web/AnalyticalReporting
2010-03-30 10:10:00,798 Mkdir - Created dir: /export/home/Business_Objects/global/deployment/workdir/tomcat55/resources/web/AnalyticalReporting
2010-03-30 10:10:00,828 Mkdir - Created dir: /export/home/Business_Objects/global/deployment/workdir/tomcat55/resources/AnalyticalReporting
2010-03-30 10:19:32,016 *ExecTask - java.io.EOFException: Unexpected end of ZLIB input stream
2010-03-30 10:19:32,016 ExecTask - at java.util.zip.InflaterInputStream.fill(InflaterInputStream.java(Compiled Code))
2010-03-30 10:19:32,017 ExecTask - at java.util.zip.InflaterInputStream.read(InflaterInputStream.java(Compiled Code))
2010-03-30 10:19:32,017 ExecTask - at java.util.zip.ZipInputStream.read(ZipInputStream.java(Compiled Code))
2010-03-30 10:19:32,017 ExecTask - at sun.tools.jar.Main.extractFile(Main.java(Compiled Code))
2010-03-30 10:19:32,017 ExecTask - at sun.tools.jar.Main.extract(Main.java(Compiled Code))
2010-03-30 10:19:32,025 ExecTask - at sun.tools.jar.Main.run(Main.java:228)
2010-03-30 10:19:32,025 ExecTask - at sun.tools.jar.Main.main(Main.java:944)
2010-03-30 10:19:32,051 ExecTask - Result: 1
2010-03-30 10:19:32,162 Echo - Adding 'webiApplet/**' to the content to bundle with AnalyticalReporting's war file
2010-03-30 10:19:32,302 Jar - error while reading original manifest: Error opening zip file /export/home/Business_Objects/global/deployment/workdir/tomc
at55/application/AnalyticalReporting.war
2010-03-30 10:19:35,354 Jar - Building jar: /export/home/Business_Objects/global/deployment/workdir/tomcat55/application/AnalyticalReporting.war
2010-03-30 10:20:29,036 Zip - Building zip: /export/home/Business_Objects/global/deployment/workdir/tomcat55/resources/AnalyticalReporting.zip
2010-03-30 10:23:58,561 Mkdir - Created dir: /export/home/Business_Objects/global/deployment/workdir/tomcat55/resources/web/AnalyticalReporting/WEB-INF
2010-03-30 10:23:58,564 Copy - Copying 1 file to /export/home/Business_Objects/global/deployment/workdir/tomcat55/resources/web/AnalyticalReporting/WEB-I
NF
2010-03-30 10:23:58,597 Delete - Deleting directory /export/home/Business_Objects/global/deployment/workdir/tomcat55/resources/AnalyticalReporting
2010-03-30 10:35:00,636 Target - Target "expand_and_package" finished.Hi,
Don't know which of this factors solved the problem:
1. Error server:
AIX 5.2
jdk 1.3.17 (minimum from docu: 1.3.11)
$ORACLE_HOME wasn't in the begining of $PATH
2. success server:
AIX 5.3
jdk 1.4.02
$ORACLE_HOME is now in the begining of $PATH
cheers Lao De -
Sending Control-Z to Input Stream
Hi everyone,
I'm writing an interface to a command line program, and
one of it's features is that it will accept "forms" through
standard input. The default is that notepad will open
when the command is typed, and you can edit the form
through there.
To accept the form through standard input, you have to
send it the form, and then tell it the form is complete.
This is done using the CTRL-Z keypress, at least when
typing the form in with the keyboard.
I need to do this with Java.
There is another post which poses the same question at
http://forum.java.sun.com/thread.jsp?forum=1&thread=3050
so I attempted that solution.. and that didn't work.
I had the system print out the form as it was being written,
and the form displayed properly, followed by what was
supposed to be a CTRL-Z character, which appeared
on screen (DOS Window) as an arrow pointing right.
Here is the code constructing the form and adding what i've been told is "ctrl-z":
new StringBuffer(form+System.getProperty("line.separator")).append(CTRL_Z).append(System.getProperty("line.separator")))CTRL_Z is defined as:
public static final char CTRL_Z = 26;Does anyone have any other suggestions that might be able to help me?
If you need more information/code provided, I can do so.
Thanks for any help!
Kefka.You can't actually send anything to an input stream. But let's suppose you have an output stream somewhere that is connected to the standard input of this command line program. Try sending a byte, not a character, that contains 26 to it (yes, ctrl-z is indeed 26). This has a better chance of working than the character idea, because Java is going to translate your character-26 from Unicode to bytes using your system's default encoding. And I can't predict what that might end up as. But it will leave the byte 26 alone and just send it... I hope. Can't guarantee this.
-
How to get file input stream from the client machine by JSF Fileupload API?
Dear Friends,
How to get the file input stream from the client machine by JSF HtmlFileupload or fileupload API. At present, if i execute the file upload code in the client machine, it is able to get the local path of the file and looking for the file in server machine. So i am getting FileNotFoundException.
E.g., If a file is located at client machine at following location means "C:\Test\Test.txt",
uploadClass.getFileuploadComponent().getFilename().toString() returns "C:\Test\Test.txt". But it is looking for that file in server and throwing FileNotFoundException.
Please post your replies soon.
Thanks,
JPDepends on which version of JSF you're using. If JSF 1.2, I wouldn't even bother trying to hack this into JSF itself unless you can use something like Seam 2 or richfaces.
http://docs.jboss.org/richfaces/latest_3_3_X/en/devguide/html/rich_fileUpload.html
http://docs.jboss.org/seam/2.2.1.CR3/reference/en-US/html/controls.html#d0e29259 (look for s:fileUpload)
But if I were you, a simple non-jsf form with a servlet works best for taking file uploads.
As for JSF 2.0, there are other ways of getting it done.
http://balusc.blogspot.com/2009/12/uploading-files-with-jsf-20-and-servlet.html -
How to get input stream of other application
Using Java is their any way to get the input stream of another applicaton?. For example i will start a java program and minimize it. Then i will start a notepad and type some thing in it. Java program should print all matters i am typed in notepad.
Is it possible using java?
Thanks in advanceYou have many ways to do that in C++. Read about Hooks and you will understand how u can do that. Anyway, even without hooks, u can get the messages from other applications in C++. So, let C++ get the data from other applications for you and let ur java program get data from the C++ program.
-
Parse XML input stream (no .xml file)?
i have a java applet calling a web service that returns XML data as an input stream (char by char from SOAP) to this applet. if i append a all the chars to a string, is there some XML tool that will parse the string as if it were an XML document (like a getElement functions)?
the applet cannot write the data to a .xml file, and i don't want to mess around with .jarsigning. any ideas?
thanks,
jonathanThe XML parsers you are likely to be using support receiving input from a variety of sources besides files. For example you could parse XML from a String variable by passing a StringReader wrapping that String to the parser. Check the documentation for more details.
-
Java.io.EOFException: Unexpected end of ZLIB input stream
Hi,
I am reading .gz file in servlet and writing it in output stream. It works fine for smaller files. For larger file when I reading file and writing output I am getting exceptions as below in order.
8/6/09 9:52:28:953 CDT] 00000029 ServletWrappe E SRVE0068E: Could not invoke the service() method on servlet /WEB-INF/pages/TilesTemplate/layouttemplate.jsp. Exception thrown : java.lang.IllegalStateException: SRVE0199E: OutputStream already obtained
at com.ibm.ws.webcontainer.srt.SRTServletResponse.getWriter(SRTServletResponse.java:489)
at org.apache.jasper.runtime.JspWriterImpl.initOut(JspWriterImpl.java:170)
at org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:163)
at org.apache.jasper.runtime.PageContextImpl.release(PageContextImpl.java:227)
---- Begin backtrace for Nested Throwables
java.lang.IllegalStateException: SRVE0199E: OutputStream already obtained
at com.ibm.ws.webcontainer.srt.SRTServletResponse.getWriter(SRTServletResponse.java:489)
at org.apache.jasper.runtime.JspWriterImpl.initOut(JspWriterImpl.java:170)
at org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:163)
*[8/6/09 9:52:28:625 CDT] 00000029 SystemErr R java.io.EOFException: Unexpected end of ZLIB input stream*
*[8/6/09 9:52:28:656 CDT] 00000029 SystemErr R at java.util.zip.InflaterInputStream.fill(InflaterInputStream.java:238)*
*[8/6/09 9:52:28:656 CDT] 00000029 SystemErr R at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:157)*
*[8/6/09 9:52:28:656 CDT] 00000029 SystemErr R at java.util.zip.GZIPInputStream.read(GZIPInputStream.java:109)*
*[8/6/09 9:52:28:656 CDT] 00000029 SystemErr R at java.io.FilterInputStream.read(FilterInputStream.java:110)*
*[8/6/09 9:52:28:656 CDT] 00000029 SystemErr R at sun.nio.cs.StreamDecoder$ConverterSD.implRead(StreamDecoder.java:325)*
*[8/6/09 9:52:28:656 CDT] 00000029 SystemErr R at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:223)*
*[8/6/09 9:52:28:656 CDT] 00000029 SystemErr R at java.io.InputStreamReader.read(InputStreamReader.java:208)*
*[8/6/09 9:52:28:656 CDT] 00000029 SystemErr R at java.io.BufferedReader.fill(BufferedReader.java:153)*
*[8/6/09 9:52:28:656 CDT] 00000029 SystemErr R at java.io.BufferedReader.readLine(BufferedReader.java:316)*
*[8/6/09 9:52:28:656 CDT] 00000029 SystemErr R at java.io.BufferedReader.readLine(BufferedReader.java:379)*
*[8/*My suggestion would be to run your code as a plain old Java application. Why use a servlet environment to test the problem? There's just too many things going on. So first see if it works the same way in a Java application. If it does, or if it doesn't, you then know where to go next.
-
How to read a file as an input stream after it's posted in an HTML form ?
Hello,
I want to read client file after it's posted in an HTML form. But, I don't want to upload it to filesystem or database. I want to read posted file as an input stream. How can I do that ?
thanks in advance...A couple of things. If you have a FILE field in your form, the enctype of the form must be multipart/form-data. Check this link
http://www.htmlhelp.com/reference/html40/forms/form.html
Also, when a file is uploaded you cannot use the regular methods to get at the name/value pairs or the file itself. You'll have to use a utility like MultiPartRequest or write your own based on the RFC for Multipart requests.
http://www.servlets.com/cos/javadoc/com/oreilly/servlet/MultipartRequest.html
You will need some temporary file system to store this and then delete it when you are done with it.
hth -
Hi Guys,
Would appreciate any help here. Basically my web application recieved XML from a URL, and transforming it straight from the URL was causing problems. So I've found a way around it but its too cpu intensive for my liking.
I now convert the URL to a string, convert the string to a byte array, and then stream the byte array.
So basically I'm asking, is there a better way of converting the URL to an input stream than my code below...
URL source = null;
SAXBuilder builder;
org.jdom.Document doc;
source = new URL(xslFile);
builder = new SAXBuilder();
doc = builder.build(source);
String xslData = Xml.getRawString(doc);
byte [] barrBt = xslData.getBytes();
ByteArrayInputStream barrInputStream2 = new ByteArrayInputStream(barrBt);
processor.process(xmlDomSource,
new StreamSource(barrInputStream2),
_request,
_response,
_xslParameters,
thisSessionInfo);Seems to me a better way to do it would be to solve the problems associated with parsing directly from the URL. They should be solvable since if your code can read from the URL then so can the parser.
However if you want to save some processing time, don't convert the XML from bytes to String and then back to bytes again. (You also run the risk of damaging the XML because you may not be doing those conversions with the encoding declared in the XML, but that's a separate problem.)
Maybe you are looking for
-
Not Allowing Goods Movements for the confirmed quantity in the delivery
Hi Gurus, I would like know how to make the system not allowing movement for a batch at MB11 when that batch of one material is confirmed in a delivery? ex: In the delivery: material number: 9009, Batch 0000A and quantity is 10. And there is no mo
-
Importing DVD-RWs into premiere pro
Hi I am a Media Students student doing a work project and some of the video I want to edit is on DVD RW small cds. When I try to import them it won't work, usually it freezes or it won't let me select them to add them to my project. They are from a C
-
Error downloading Address Book
Hi, I am facing the following error while downloading address book manually. Anyone please help. Regards, Anees
-
ITunes Won't Open With iPhone or iPad
I do want iTunes to launch when my iPhone and iPad are connected. That option is checked in the summery under devices. But iTunes won't launch. Don't know if this is aniPhone/iPad problem or iTunes. Any help most welcome.
-
I need to buy a motherboard for my laptop Thinkpad X61, Type 7676-A29, S/N xxxxxxx I will appreciate if anybody can tell me Where I could buy it? Thanks Moderator Note; s/n edited for members own protection