Search Results

Search found 268 results on 11 pages for 'outputstream'.

Page 6/11 | < Previous Page | 2 3 4 5 6 7 8 9 10 11  | Next Page >

  • Caching the xml response from a HttpHandler

    - by Blankman
    My HttpHandler looks like: public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/xml"; XmlWriter writer = new XmlTextWriter(context.Response.OutputStream, Encoding.UTF8); writer.WriteStartDocument(); writer.WriteStartElement("ProductFeed"); DataTable dt = GetStuff(); for(...) { } writer.WriteEndElement(); writer.WriteEndDocument(); writer.Flush(); writer.Close(); } How can I cache the entire xml document that I am generating? Or do I only have the option of caching the DataTable object?

    Read the article

  • __spin_lock while writing the bytes in NSOutputStream

    - by Mohammed Sadiq
    HI all, I have a issue that when I try to write some bytes in the outputstream, I am getting the bad access. The code is as follows : int writtenBytes = [_os write:[packetInBytes bytes] maxLength:lengthOfPacket]; where the "packetInBytes" points to NSData and "lengthOfPacket" corresponds to the data length, and _os represents the NSOutputStream. The call stack from the debugger is as follows : 0 0xffff0269 in __spin_lock 1 0x302a6098 in CFSocketDisableCallBacks 2 0x003b46d0 in SocketStream::write 3 0x302402c3 in CFWriteStreamWrite 4 0x0001b423 in -[Writer write:] at Writer.m:96 5 0x0001b5ef in -[Writer run] at Writer.m:111 6 0x3050a79d in -[NSThread main] 7 0x3050a338 in NSThread__main 8 0x91a27fe1 in _pthread_start 9 0x91a27e66 in thread_start** I am not getting this issue always. I get this issue execute my code for some 5 or more times ... I have checked all the params that i pass to the write function have its values and not nil. Any help would be greatly appreciated Best Regards, MOhammed Sadiq.

    Read the article

  • Create Zip file from stream and download it

    - by Navid Farhadi
    I have a DataTable that i want to convert it to xml and then zip it, using DotNetZip. finally user can download it via Asp.Net webpage. My code in below dt.TableName = "Declaration"; MemoryStream stream = new MemoryStream(); dt.WriteXml(stream); ZipFile zipFile = new ZipFile(); zipFile.AddEntry("Report.xml", "", stream); Response.ClearContent(); Response.ClearHeaders(); Response.AppendHeader("content-disposition", "attachment; filename=Report.zip"); zipFile.Save(Response.OutputStream); //Response.Write(zipstream); zipFile.Dispose(); the xml file in zip file is empty.

    Read the article

  • What Am I Missing? : iPhone Objective-C NSInputStream initWithData

    - by gabe
    I'm creating an NSInputStream from an NSData object but once created the stream reports NO for hasBytesAvailable: NSData* data = [outputStream propertyForKey: NSStreamDataWrittenToMemoryStreamKey]; NSLog(@"creating stream with data 0x%x length %d", [data bytes], [data length]); NSInputStream *insrm = [[NSInputStream alloc] initWithData:data]; [insrm open]; uint8_t* buf = NULL; NSUInteger len; BOOL result = [insrm getBuffer:&buf length:&len]; BOOL hasbytes = [insrm hasBytesAvailable]; NSLog(@"getBuffer:%d hasBytes:%d", result, hasbytes); NSLog(@"created inputstream data %d len %d", buf, len); Log: [26797:20b] creating stream with data 0x7050000 length 34672 [26797:20b] getBuffer:0 hasBytes:0 [26797:20b] created inputstream data 0 len 0 What am I missing here?

    Read the article

  • How to stream video content in asp.net?

    - by Kon
    Hi, I have the following code which downloads video content: WebRequest wreq = (HttpWebRequest)WebRequest.Create(url); using (HttpWebResponse wresp = (HttpWebResponse)wreq.GetResponse()) using (Stream mystream = wresp.GetResponseStream()) { using (BinaryReader reader = new BinaryReader(mystream)) { int length = Convert.ToInt32(wresp.ContentLength); byte[] buffer = new byte[length]; buffer = reader.ReadBytes(length); Response.Clear(); Response.Buffer = false; Response.ContentType = "video/mp4"; //Response.BinaryWrite(buffer); Response.OutputStream.Write(buffer, 0, buffer.Length); Response.End(); } } But the problem is that the whole file downloads before being played. How can I make it stream and play as it's still downloading? Or is this up to the client/receiver application to manage?

    Read the article

  • Spring: Inject static member (System.in) via constructor

    - by Julian Lettner
    I wrote some sort of console client for a simple application. To be more flexible, I thought it would be nice to only depend on java.io.Input-/OutputStream, instead of accessing System.in/out directly. I renamed the class ConsoleClient to StreamClient, added setters and made sure that the instance fields are used instead of System.in/out. At the moment my client code looks like this: ApplicationContext appCtx = new ClassPathXmlApplicationContext("..."); StreamClient cc = (StreamClient) appCtx.getBean("streamClient"); cc.setInputStream(System.in); cc.setOutputStream(System.out); cc.run(); // start client Question: Is there a way to move lines 3 and 4 into the Spring configuration (preferably constructor injection)? Thanks for your time.

    Read the article

  • A generic error occurred in GDI+.

    - by Pinu
    A generic error occurred in GDI+ [ExternalException (0x80004005): A generic error occurred in GDI+.] System.Drawing.Image.Save(Stream stream, ImageCodecInfo encoder, EncoderParameters encoderParams) +615257 I have a webpage in which a pdf is converted to png, and using the response.outputstream it is displayed. when i run this on my local machine is works fine. but when i run the same code on server is throws this exception. my question is , where i could look in for error. as there is no inner exception or any other information provided. only clue is that it's happening on Image.Save , but the same code works perfectly fine on my local machine , then y is it not working on production???

    Read the article

  • Extract page from PDF using iText and clojure

    - by KobbyPemson
    I am trying to extract a single page from a pdf with clojure by translating the splitPDF method I found here http://viralpatel.net/blogs/itext-tutorial-merge-split-pdf-files-using-itext-jar/ I keep getting this error IOException Stream Closed java.io.FileOutputStream.writeBytes (:-2) This prevents me from opening the document while the repl is still open. Once I close the repl I'm able to access the document. Why do I get the error? How do I fix it ? How can I make it more clojurey? (import '(com.itextpdf.text Document) '(com.itextpdf.text.pdf PdfReader PdfWriter PdfContentByte PdfImportedPage BaseFont) '(java.io File FileInputStream FileOutputStream InputStream OutputStream)) (defn extract-page [src dest pagenum] (with-open [ d (Document.) os (FileOutputStream. dest)] (let [ srcpdf (->> src FileInputStream. PdfReader.) destpdf (PdfWriter/getInstance d os)] (doto d (.open ) (.newPage )) (.addTemplate (.getDirectContent destpdf) (.getImportedPage destpdf srcpdf pagenum) 0 0))))

    Read the article

  • http streaming using java servlet

    - by Shamik
    I have a servlet based web application which produces two sets of data. One set of data in the webpage which is essential and other set which is optional. I would like to render the essential data as fast as possible and then stream the optional data. I was thinking of writing the essential data to the output stream of HttpServletRequest and then call HttpServletRequest.flushBuffer() to commit the response to the client, but do not return from the servlet code, but instead create the optional data , write that to the outputstream again and then return from servlet code. What are the things that could go wrong in this scheme ? Is this a standard practice to achieve this goal?

    Read the article

  • C# "Could not find a part of the path" - Creating Local File

    - by Pyronaut
    I am trying to write to a folder that is located on my C:\ drive. I keep getting the error of : Could not find a part of the path .. etc My filepath looks basically like this : C:\WebRoot\ManagedFiles\folder\thumbs\5c27a312-343e-4bdf-b294-0d599330c42d\Image\lighthouse.jpg And I am writing to it like so : using (MemoryStream memoryStream = new MemoryStream()) { thumbImage.Save(memoryStream, ImageFormat.Jpeg); using (FileStream diskCacheStream = new FileStream(cachePath, FileMode.CreateNew)) { memoryStream.WriteTo(diskCacheStream); } memoryStream.WriteTo(context.Response.OutputStream); } Don't worry too much about the memory stream. It is just outputting it (After I save it). Since I am creating a file, I am a bit perplexed as to why it cannot find the file (Shouldn't it just write to where I tell it to, regardless?). The strange thing is, It has no issue when I'm testing it above using File.Exists. Obviously that is returning false, But it means that atleast my Filepath is semi legit. Any help is much appreciated.

    Read the article

  • I'm using the correct content type & Headers so Why is FireFox saving Zip Files without extensions

    - by The_AlienCoder
    Users on my site have the option to download all the photos in an album as a zip file.The Zip file is dynamically created and saved to Response.OutPutStream to be detected as a file download on the user's browser. Here is the Header and Content-type I am outputing context.Response.AddHeader("Content-Disposition", "attachment; filename=Photos.zip"); context.Response.ContentType = "application/x-zip-compressed"; ..Well everything works fine with every browser except FireFox. Although Firefox correctly detects the download as a Zip file, It saves the file without the .zip extension. I thought adding this header context.Response.AddHeader("Content-Disposition", "attachment; filename=Photos.zip"); ..is supposed to force FF to save the extension. I believe I am following the correct protocol so why is FF behaving this way and how do I fix this?

    Read the article

  • richfaces keepAlive not working

    - by Jurgen H
    I have a mediaOutput tag which, in its createContent attribute, requires the backing bean to be in a certain state. A list of values, which is filled in an init method, must be available. I therefore added a keepAlive tag for the whole backing bean. I now indeed see the backingBean in stead of some (richfaces) proxy bean, but the filled list is null again. How to make this possible? I checked that the init method was called and that the list is filled in in the init method. <a4j:keepAlive beanName="myBean" /> <a4j:mediaOutput createContent="#{myBean.writeChart}" ... /> The backing bean public class MyBean implements Serializable { public List list; public void init(ActionEvent event) { // call some resource to fill the list list = service.getItems(); } public void writeChart(final OutputStream out, final Object data) throws IOException { // list is null } // getters & setters }

    Read the article

  • download file in iframe in IE

    - by Estelle
    in a webpage I have a link to let the user download file, such as, "showfile.aspx?filename=xxx" in showfile.aspx, I send the file using Response.OutputStream.Write method. now I get some problem when somebody put this webpage in an IFrame and open in IE, as I checked the code, showfile.aspx is requested twice when clicks the link, and in the second time the cookies of authorization and session Id are missing. I tried to add the p3p header but not working. my question is, is this how the IE designed with iframe? is there anyway to work around? thanks.

    Read the article

  • Opening response stream in silverlight

    - by John Maloney
    Hello, I am attempting to return a image from a server using Silverlight 3. The server returns the Response stream like this: context.Response.ContentType = imageFactory.ContentType imgStream.WriteTo(context.Response.OutputStream) imgStream.Close() context.Response.End() On the Silverlight client I am handling the stream like: Dim request As HttpWebRequest = result.AsyncState Dim response As HttpWebResponse = request.EndGetResponse(result) Dim responseStream As IO.Stream = response.GetResponseStream() I want to take that stream and open the browsers save dialog, one option I have explored is using the Html.Window.Navigate(New Uri("image url")) and this opened the correct browser default dialog but it is not an option because I need to send extended information(e.g. XML) to the server through the HttpRequest.Headers.Item and the Navigate doesn't allow this. How can I take a Response Stream and force the default browser Save dialog to appear from the Silverlight Application without using the Html.Window.Navigate(New Uri("image url"))?

    Read the article

  • setting a timeout for an InputStreamreader variable

    - by Noona
    I have a server running that accepts connections made through client sockets, I need to read the input from this client socket, now suppose the client opened a connection to my server without sending anything through the server's socket outputstream, in this case, while my server tried to read the input through the client socket's inputstream, an exception will be thrown, but before the exception is thrown i would like a timeout say of 5 sec, how can I do this? currently here's how my code looks like on the server side: try { InputStreamReader clientInputStream = new InputStreamReader(clientSocket.getInputStream()); int c; StringBuffer requestBuffer = new StringBuffer(); while ((c = clientInputStream.read()) != -1) { requestBuffer.append((char) c); if (requestBuffer.toString().endsWith(("\r\n\r\n"))) break; } request = new Request(requestBuffer.toString(), clientSocket); } catch (Exception e) // catch any possible exception in order to keep the thread running { try { if (clientSocket != null) clientSocket.close(); } catch (IOException ex) { ex.printStackTrace(); } System.err.println(e); //e.printStackTrace(); }

    Read the article

  • Java Client-Server problem when sending multiple files

    - by Jim
    Client public void transferImage() { File file = new File(ServerStats.clientFolder); String[] files = file.list(); int numFiles = files.length; boolean done = false; BufferedInputStream bis; BufferedOutputStream bos; int num; byte[] byteArray; long count; long len; Socket socket = null ; while (!done){ try{ socket = new Socket(ServerStats.imgServerName,ServerStats.imgServerPort) ; InputStream inStream = socket.getInputStream() ; OutputStream outStream = socket.getOutputStream() ; System.out.println("Connected to : " + ServerStats.imgServerName); BufferedReader inm = new BufferedReader(new InputStreamReader(inStream)); PrintWriter out = new PrintWriter(outStream, true /* autoFlush */); for (int itor = 0; itor < numFiles; itor++) { String fileName = files[itor]; System.out.println("transfer: " + fileName); File sentFile = new File(fileName); len = sentFile.length(); len++; System.out.println(len); out.println(len); out.println(sentFile); //SENDFILE bis = new BufferedInputStream(new FileInputStream(fileName)); bos = new BufferedOutputStream(socket.getOutputStream( )); byteArray = new byte[1000000]; count = 0; while ( count < len ){ num = bis.read(byteArray); bos.write(byteArray,0,num); count++; } bos.close(); bis.close(); System.out.println("file done: " + itor); } done = true; }catch (Exception e) { System.err.println(e) ; } } } Server public static void main(String[] args) { BufferedInputStream bis; BufferedOutputStream bos; int num; File file = new File(ServerStats.serverFolder); if (!(file.exists())){ file.mkdir(); } try { int i = 1; ServerSocket socket = new ServerSocket(ServerStats.imgServerPort); Socket incoming = socket.accept(); System.out.println("Spawning " + i); try { try{ if (!(file.exists())){ file.mkdir(); } InputStream inStream = incoming.getInputStream(); OutputStream outStream = incoming.getOutputStream(); BufferedReader inm = new BufferedReader(new InputStreamReader(inStream)); PrintWriter out = new PrintWriter(outStream, true /* autoFlush */); String length2 = inm.readLine(); System.out.println(length2); String filename = inm.readLine(); System.out.println("Filename = " + filename); out.println("ACK: Filename received = " + filename); //RECIEVE and WRITE FILE byte[] receivedData = new byte[1000000]; bis = new BufferedInputStream(incoming.getInputStream()); bos = new BufferedOutputStream(new FileOutputStream(ServerStats.serverFolder + "/" + filename)); long length = (long)Integer.parseInt(length2); length++; long counter = 0; while (counter < length){ num = bis.read(receivedData); bos.write(receivedData,0,num); counter ++; } System.out.println(counter); bos.close(); bis.close(); File receivedFile = new File(filename); long receivedLen = receivedFile.length(); out.println("ACK: Length of received file = " + receivedLen); } finally { incoming.close(); } } catch (IOException e){ e.printStackTrace(); } } catch (IOException e1){ e1.printStackTrace(); } } The code is some I found, and I have slightly modified it, but I am having problems transferring multiple images over the server. Output on Client: run ServerQueue.Client Connected to : localhost transfer: Picture 012.jpg 1312743 java.lang.ArrayIndexOutOfBoundsException Connected to : localhost transfer: Picture 012.jpg 1312743 Cant seem to get it to transfer multiple images. But bothsides I think crash or something because the file never finishes transfering

    Read the article

  • reading unicode

    - by user121196
    I'm using java io to retrieve text from a server that might output character such as é. then output it using System.err, they turn out to be '?'. I am using UTF8 encoding. what's wrong? int len=0; char[]buffer=new char[1024]; OutputStream os = sock.getOutputStream(); InputStream is = sock.getInputStream(); os.write(query.getBytes("UTF8"));//iso8859_1")); Reader reader = new InputStreamReader(is, Charset.forName("UTF-8")); do{ len = reader.read(buffer); if (len0) { if(outstring==null)outstring=new StringBuffer(); outstring.append(buffer,0,len); } }while(len0); System.err.println(outstring);

    Read the article

  • FileInputStream and FileOutputStream to the same file: Is a read() guaranteed to see all write()s that "happened before"?

    - by user946850
    I am using a file as a cache for big data. One thread writes to it sequentially, another thread reads it sequentially. Can I be sure that all data that has been written (by write()) in one thread can be read() from another thread, assuming a proper "happens-before" relationship in terms of the Java memory model? Is this behavior documented? EDIT: In my JDK, FileOutputSream does not override flush(), and OutputStream.flush() is empty. That's why I'm wondering... EDIT^2: The streams in question are owned exclusively by a class that I have full control of. Each stream is guaranteed to be accesses by one thread only. My tests show that it works as expected, but I'm still wondering if this is guaranteed and documented. See also this related discussion: http://chat.stackoverflow.com/rooms/17598/discussion-between-hussain-al-mutawa-and-user946850

    Read the article

  • How to explicitly terminate http connection from server with no response header

    - by Gagandip
    I am developing a server simulator for one of my client application. I am using GlassFish server. I have to simulate a http connection terminate condition in my server application. Is there a way by which I can explicitly terminate a connection from server side such that client does not receive any response header. Currently I have tried many options like closing the response outputStream. But in every case a http 200 OK message is delivered to the client application. I would like to consume the http-request and do not want to return anything to the client. I am using a simple conrtroller servlet and had overridden doGet() and doPost() functions.

    Read the article

  • How to read binary column in database into image on asp.net page?

    - by marko
    I want to read from database where I've stored a image in binary field and display a image. while (reader.Read()) { byte[] imgarr = (byte[])reader["file"]; Stream s = new MemoryStream(imgarr); System.Drawing.Image image = System.Drawing.Image.FromStream(s); Graphics g = Graphics.FromImage(image); g.DrawImage(image, new Point(400, 10)); image.Save(Response.OutputStream, ImageFormat.Jpeg); g.Dispose(); image.Dispose(); } con.Close(); This piece of code doesn't work: System.Drawing.Image image = System.Drawing.Image.FromStream(s); What am I doing wrong?

    Read the article

  • Using jQuery, how do I way attach a string array as a http parameter to a http request?

    - by predhme
    I have a spring controller with a request mapping as follows @RequestMapping("/downloadSelected") public void downloadSelected(@RequestParam String[] ids) { // retrieve the file and write it to the http response outputstream } I have an html table of objects which for every row has a checkbox with the id of the object as the value. When they submit, I have a jQuery callback to serialize all ids. I want to stick those ids into an http request parameter called, "ids" so that I can grab them easily. I figured I could do the following var ids = $("#downloadall").serializeArray(); Then I would need to take each of the ids and add them to a request param called ids. But is there a "standard" way to do this? Like using jQuery?

    Read the article

  • Removing response.End() includes the html of the page.

    - by vinay_rockin
    HttpResponse response = Context.Http.Response; response.Headers.Clear(); response.Clear(); response.ContentType = Component.OverrideMimeType ? Component.MimeType : "application/download"; response.AppendHeader("Content-Disposition", String.Format("attachment; filename=\"{0}\"", HttpUtility.HtmlEncode(Path.GetFileName(file.FileName)))); response.OutputStream.Write(file.Contents, 0, file.Contents.Length); response.Flush(); // response.End(); if I use response.End() it throws exception and if I comment response.End() it includes the html of the page on which the download link resides. how want to download file with introducing this exta html. Any Idea how to fix this?

    Read the article

  • Send a String[] ArrayList over Socket connection

    - by Duncan Palmer
    So i'm trying to send a String[] Array/List over an open socket connection. I currently have this code: Sending: public void sendData() { try { OutputStream socketStream = socket.getOutputStream(); ObjectOutputStream objectOutput = new ObjectOutputStream(socketStream); objectOutput.writeObject(new String[] {"Test", "Test2", "Test3"}); objectOutput.close(); socketStream.close(); } catch (Exception e) { System.out.println(e.toString()); } } Recieving: public Object readData() { try { InputStream socketStream = socket.getInputStream(); ObjectInputStream objectInput = new ObjectInputStream(new GZIPInputStream(socketStream)); Object a = objectInput.readObject(); return a; } catch(Exception e) { return null; } } After I have recieved the String array/list on the other end I want to be able to iterate through it like I would do normally so I can get the values. My current code doesn't seem to works as it returns null as the value. is this possible?

    Read the article

  • Issues with timed out downloads via TomCat?

    - by Ira Baxter
    We get, in our opinion, a lot of failed download attempts and want to understand why. We offer downloads via an email link (typical): http://www.semanticdesigns.com/deliverEval/<productname> This is processed by Tomcat on Linux via a jsp file, with the following code: response.addHeader( "Content-Disposition", "attachment; filename=" + fileTail ); response.addHeader( "Content-Type", "application/x-msdos-program" ); byte[] buf = new byte[8192]; int read; try { java.io.FileInputStream input = new java.io.FileInputStream( filename ); java.io.OutputStream o = response.getOutputStream(); while( ( read = input.read( buf, 0, 8192 ) ) != -1 ){ o.write( buf, 0, read ); } o.flush(); } catch( Exception e ){ util.fatalError( request.getRequestURI(), "Error sending file '" + filename + "' to client", e ); throw e; } We get a lot of reported errors (about 50% error rate): URI --- /deliverEval/download.jsp Code Message: Error sending file '/home/sd/ShippingMasters/DMS/Domains/C/GCC3/Tools/TestCoverage/SD_C~GCC3_TestCoverage.1.6.12.exe' to client Stack Trace ----------- null at org.apache.coyote.tomcat5.OutputBuffer.realWriteBytes(byte[], int, int) (Unknown Source) at org.apache.tomcat.util.buf.ByteChunk.append(byte[], int, int) (Unknown Source) at org.apache.coyote.tomcat5.OutputBuffer.writeBytes(byte[], int, int) (Unknown Source) at org.apache.coyote.tomcat5.OutputBuffer.write(byte[], int, int) (Unknown Source) at org.apache.coyote.tomcat5.CoyoteOutputStream.write(byte[], int, int) (Unknown Source) at org.apache.jsp.deliverEval.download_jsp._jspService(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) (Unknown Source) at org.apache.jasper.runtime.HttpJspBase.service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) (Unknown Source) at javax.servlet.http.HttpServlet.service(javax.servlet.ServletRequest, javax.servlet.ServletResponse) (Unknown Source) at org.apache.jasper.servlet.JspServletWrapper.service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, boolean) (Unknown Source) at org.apache.jasper.servlet.JspServlet.serviceJspFile(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.String, java.lang.Throwable, boolean) (Unknown Source) at org.apache.jasper.servlet.JspServlet.service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) (Unknown Source) at javax.servlet.http.HttpServlet.service(javax.servlet.ServletRequest, javax.servlet.ServletResponse) (Unknown Source) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse) (Unknown Source) at org.apache.catalina.core.ApplicationFilterChain.doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse) (Unknown Source) at org.apache.catalina.core.StandardWrapperValve.invoke(org.apache.catalina.Request, org.apache.catalina.Response, org.apache.catalina.ValveContext) (Unknown Source) We don't understand why this rate should be so high. Is there any way to get more information about the cause of the error? It is useful to know that these are pretty big documents, 3-50 megabytes. They reside on the Linux server so reading them is just a local disk read, and is unlikely to be a contributor to the problem. But sheer size might be an issue for the recipients browser? Is this kind of error rate typical for downloads? My personal experience downloading other's documents suggests no; our internal attempts show this to be very reliable, but we're operating on our internal network for such experiments so we're missing the complexity of the intervening internet.

    Read the article

  • Problem while running the j2me application

    - by Paru
    I am not able to view any content in the emulator while running the application. The Build is not failed and i am able run the application successfully. While i am closing the emulator i am getting an error. i can provide both code and log here. import javax.microedition.lcdui.; import javax.microedition.midlet.; import java.io.; import java.lang.; import javax.microedition.io.; import javax.microedition.rms.; public class Login extends MIDlet implements CommandListener { TextField ItemName=null; TextField ItemNo=null; TextField UserName=null; TextField Password=null; Form authForm,mainscreen; TextBox t = null; StringBuffer b = new StringBuffer(); private Display myDisplay = null; private Command okCommand = new Command("Login", Command.OK, 1); private Command exitCommand = new Command("Exit", Command.EXIT, 2); private Command sendCommand = new Command("Send", Command.OK, 1); private Command backCommand = new Command("Back", Command.BACK, 2); private Alert alert = null; public Login() { ItemName=new TextField("Item Name","",10,TextField.ANY); ItemNo=new TextField("Item No","",10,TextField.ANY); myDisplay = Display.getDisplay(this); UserName=new TextField("Your Name","",10,TextField.ANY); Password=new TextField("Password","",10,TextField.PASSWORD); authForm=new Form("Identification"); mainscreen=new Form("Logging IN"); mainscreen.addCommand(sendCommand); mainscreen.addCommand(backCommand); authForm.append(UserName); authForm.append(Password); authForm.addCommand(okCommand); authForm.addCommand(exitCommand); authForm.setCommandListener(this); myDisplay.setCurrent(authForm); } public void startApp() throws MIDletStateChangeException { } public void pauseApp() { } protected void destroyApp(boolean unconditional) throws MIDletStateChangeException { } public void commandAction(Command c, Displayable d) { if ((c == okCommand) && (d == authForm)) { if (UserName.getString().equals("") || Password.getString().equals("")){ alert = new Alert("Error", "You should enter Username and Password", null, AlertType.ERROR); alert.setTimeout(Alert.FOREVER); myDisplay.setCurrent(alert); } else{ //myDisplay.setCurrent(mainscreen); login(UserName.getString(),Password.getString()); } } if ((c == backCommand) && (d == mainscreen)) { myDisplay.setCurrent(authForm); } if ((c == exitCommand) && (d == authForm)) { notifyDestroyed(); } if ((c == sendCommand) && (d == mainscreen)) { if(ItemName.getString().equals("") || ItemNo.getString().equals("")){ } else{ sendItem(ItemName.getString(),ItemNo.getString()); } } } public void login(String UserName,String PassWord) { HttpConnection connection=null; DataInputStream in=null; String url="http://olario.net/submitpost/submitpost/login.php"; OutputStream out=null; try { connection=(HttpConnection)Connector.open(url); connection.setRequestMethod(HttpConnection.POST); connection.setRequestProperty("IF-Modified-Since", "2 Oct 2002 15:10:15 GMT"); connection.setRequestProperty("User-Agent","Profile/MIDP-1.0 Configuration/CLDC-1.0"); connection.setRequestProperty("Content-Language", "en-CA"); connection.setRequestProperty("Content-Length",""+ (UserName.length()+PassWord.length())); connection.setRequestProperty("username",UserName); connection.setRequestProperty("password",PassWord); out = connection.openDataOutputStream(); out.flush(); in = connection.openDataInputStream(); int ch; while((ch = in.read()) != -1) { b.append((char) ch); //System.out.println((char)ch); } //t = new TextBox("Reply",b.toString(),1024,0); //mainscreen.append(b.toString()); String auth=b.toString(); if(in!=null) in.close(); if(out!=null) out.close(); if(connection!=null) connection.close(); if(auth.equals("ok")){ mainscreen.setCommandListener(this); myDisplay.setCurrent(mainscreen); } } catch(IOException x){ } } public void sendItem(String itemname,String itemno){ HttpConnection connection=null; DataInputStream in=null; String url="http://www.olario.net/submitpost/submitpost/submitPost.php"; OutputStream out=null; try { connection=(HttpConnection)Connector.open(url); connection.setRequestMethod(HttpConnection.POST); connection.setRequestProperty("IF-Modified-Since", "2 Oct 2002 15:10:15 GMT"); connection.setRequestProperty("User-Agent","Profile/MIDP-1.0 Configuration/CLDC-1.0"); connection.setRequestProperty("Content-Language", "en-CA"); connection.setRequestProperty("Content-Length",""+ (itemname.length()+itemno.length())); connection.setRequestProperty("itemCode",itemname); connection.setRequestProperty("qty",itemno); out = connection.openDataOutputStream(); out.flush(); in = connection.openDataInputStream(); int ch; while((ch = in.read()) != -1) { b.append((char) ch); //System.out.println((char)ch); } //t = new TextBox("Reply",b.toString(),1024,0); //mainscreen.append(b.toString()); String send=b.toString(); if(in!=null) in.close(); if(out!=null) out.close(); if(connection!=null) connection.close(); if(send.equals("added")){ alert = new Alert("Error", "Send Successfully", null, AlertType.INFO); alert.setTimeout(Alert.FOREVER); myDisplay.setCurrent(alert); } } catch(IOException x){ } } } and the log is pre-init: pre-load-properties: exists.config.active: exists.netbeans.user: exists.user.properties.file: load-properties: exists.platform.active: exists.platform.configuration: exists.platform.profile: basic-init: cldc-pre-init: cldc-init: cdc-init: ricoh-pre-init: ricoh-init: semc-pre-init: semc-init: savaje-pre-init: savaje-init: sjmc-pre-init: sjmc-init: ojec-pre-init: ojec-init: cdc-hi-pre-init: cdc-hi-init: nokiaS80-pre-init: nokiaS80-init: nsicom-pre-init: nsicom-init: post-init: init: conditional-clean-init: conditional-clean: deps-jar: pre-preprocess: do-preprocess: Pre-processing 0 file(s) into /home/sreekumar/NetBeansProjects/Login/build/preprocessed directory. post-preprocess: preprocess: pre-compile: extract-libs: do-compile: post-compile: compile: pre-obfuscate: proguard-init: skip-obfuscation: proguard: post-obfuscate: obfuscate: lwuit-build: pre-preverify: do-preverify: post-preverify: preverify: pre-jar: set-password-init: set-keystore-password: set-alias-password: set-password: create-jad: add-configuration: add-profile: do-extra-libs: nokiaS80-prepare-j9: nokiaS80-prepare-manifest: nokiaS80-prepare-manifest-no-icon: nokiaS80-create-manifest: jad-jsr211-properties.check: jad-jsr211-properties: semc-build-j9: do-jar: nsicom-create-manifest: do-jar-no-manifest: update-jad: Updating application descriptor: /home/sreekumar/NetBeansProjects/Login/dist/Login.jad Generated "/home/sreekumar/NetBeansProjects/Login/dist/Login.jar" is 3501 bytes. sign-jar: ricoh-init-dalp: ricoh-add-app-icon: ricoh-build-dalp-with-icon: ricoh-build-dalp-without-icon: ricoh-build-dalp: savaje-prepare-icon: savaje-build-jnlp: post-jar: jar: pre-run: netmon.check: open-netmon: cldc-run: Copying 1 file to /home/sreekumar/NetBeansProjects/Login/dist/nbrun4244989945642509378 Copying 1 file to /home/sreekumar/NetBeansProjects/Login/dist/nbrun4244989945642509378 Jad URL for OTA execution: http://localhost:8082/servlet/org.netbeans.modules.mobility.project.jam.JAMServlet//home/sreekumar/NetBeansProjects/Login/dist//Login.jad Starting emulator in execution mode Running with storage root /home/sreekumar/j2mewtk/2.5.2/appdb/temp.DefaultColorPhone1 /home/sreekumar/NetBeansProjects/Login/nbproject/build-impl.xml:915: Execution failed with error code 143. BUILD FAILED (total time: 35 seconds)

    Read the article

< Previous Page | 2 3 4 5 6 7 8 9 10 11  | Next Page >