Java Development
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Remember me

Go Back   Dev Articles Community ForumsProgrammingJava Development

Add This Thread To:   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
Unread Dev Articles Community Forums Sponsor:
Old March 2nd, 2012, 02:44 PM
amsko amsko is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
Join Date: Mar 2012
Posts: 1 amsko User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 26 m 42 sec
Reputation Power: 0
Angry Need help with outputstream

I have the below code which is giving me a null pointer exception at the outputstream:

try {
URL server = new URL("http", targetServer, "(my app url)");
System.out.println("Server === "+server);
HttpURLConnection conn = (HttpURLConnection) server
System.out.println("Connection === "+conn);
conn.setRequestProperty("Content-Type", "text/xml");
conn.setRequestProperty("Content-Length", Integer

os = conn.getOutputStream();
System.out.println("Outputstream === "+os);

is = conn.getInputStream();

char[] buildRespPayload = new char[2048];
int ch;
int idx = 0;

ch =;
while (ch != -1) {
if (ch >= 0)
buildRespPayload[idx++] = (char) ch;
ch =;

Below is the Stack trace:

[3/2/12 11:19:10:753 PST] 0000002d SystemOut O inside servlet.........................
[3/2/12 11:20:08:124 PST] 0000002d SystemOut O before send request...............
[3/2/12 11:20:08:124 PST] 0000002d SystemOut O inside send request....................
[3/2/12 11:20:08:124 PST] 0000002d SystemOut O Server === server url here
[3/2/12 11:20:08:124 PST] 0000002d SystemOut O Connection === url)
[3/2/12 11:20:08:130 PST] 0000002d servlet service SRVE0068E: Uncaught exception created in one of the service methods of the servlet DSCISAlert in application dscatls. Exception created : java lang NullPointerException
at servlet.sendRequest(
at servlet.doGet(
at javax.servlet.http.HttpServlet.service(HttpServlet .java:718)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:831)
at vice(
at dleRequest(
at dleRequest(
at .handleRequest(
at t(
at est(
at (
at st(
at y(
at nk.handleDiscrimination(
at nk.handleNewRequest(
at nk.processRequest(
at nk.ready(
at adCallback.sendToDiscriminators(NewConnectionIniti
at adCallback.complete(NewConnectionInitialReadCallba
at ner.futureCompleted( :165)
at k(
at Actions(
at .java:138)
at oop(
at$ .java:905)
at$ ava:1604)

i am using the same method and target URL for a test file from my local command prompt which gives me a blank response which is ok since i dont get an error. but if this code is executed through a URL in the browser it gives me a Error 500: java.lang.NullPointerException the stack trace for which is given above..

Plz help ASAP

Reply With Quote

Viewing: Dev Articles Community ForumsProgrammingJava Development > Need help with outputstream

Developer Shed Advertisers and Affiliates

Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.

© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap