Mutiple input streams
i have two different input streams from different locations.
i want to wait for data on these streams and then process that data.
at the moment i have it like:
string a = inputa.readline();
string b = inputb.readline();
if(string a.equals(something){//do soemthing
if(string b.equals(something){//do soemthing else
but obviously this is a bad way of doing it because b may have to wait for datato come on a, and a may have to wait for data to come on b.
what is a simple alternative (pref. without threading).
thanks.
they do rather independant tasks but unfortunatly
they need to be within the same class for several
reasons.
is there no other way? would organising the if
statement in some other manner work?Not if they are truly independent. Consider the case where the code is busy with one event and the other event occurs. What will service it?
Threads, as suggested. Not multiple classes as you said - one class, multiple threads.
Similar Messages
-
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 -
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; -
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.) -
JDBC Connection reset by peer: JVM_recv in socket input stream read
Hey Guys,
Has anyone seen this issue? We get this error in our Weblogic app logs at times and no one is able to login to our application. Our database server and SQL server seem fine at a high level. Any ideas what is causing this?
com.s1.arch.persistence.exception.PersistenceException weblogic.jdbc.mssqlserver4.TdsException: I/O exception while talking to the server, java.net.SocketException: Connection reset by peer: JVM_recv in socket input stream read
Thanksplease make sure that there is no Firewall between your servers and DB server. this message usually happen when there is a fire wall between the servers. if yes please make sure that the connection time on fire wall is longer than the time needed to complete an operation another thing that you need to check if you have a fire wall which is to make sure that Oracle DBMS return the request to the same port that it is listening to (1521 default).
Maybe you are looking for
-
Hello, I'm using Jdeveloper 10.1.3.0.3.3412 on a Mac with a MySQL database. In Jdeveloper i can make a connection to the database and create adf business components I've made a JSP page with ADF on a single table. No errors when compiling. When I try
-
Vendor Outbound IDoc and Unblock Indicator...
Hi All, I am using an outbound IDoc to pass on the information of vendor master to a legacy system via PI. Basic type I am using for the same is CREMAS05. Now, when I am unblocking a vendor via XK05 and when I am changing the data of vendor, I am not
-
Auto commit in JDeveloper SQL Worksheet
Can anybody tell me how to turn OFF the autocommit in SQL Worksheet withing JDeveloper, Many Thanks in advance, Ian
-
Unicode Khmer font display problems in FrameMaker 10?
How do I get Khmer OS or any unicode Khmer font to display properly in FrameMaker 10? I am working with cambodian files in FrameMaker 10. This is what it looks like in Word (this is how it should look) This is how the same texk looks in FrameMaker 10
-
Hi All, I have to come up with some pl/sql resuable component. Please suggest what can be build. Nordik