Win a copy of GANs in ActionE this week in the AI forum
or WebAssembly in Action in the JavaScript forum!

Anurag Narayan

Ranch Hand
+ Follow
since Jul 14, 2008
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Anurag Narayan

Hi,
In my enterprise application I'm trying to generate a heavy PDF(around 800MB) and present to client for printing. The problem is that such a huge file is causing Websphere server to crash causing OutOfMemory Error.

Follwoing is the method which is returning the data to browser using response object.


* Utility method that demonstrates how to write an input stream to the server's local file system.
*/
private void writeToBrowser(ByteArrayInputStream byteArrayInputStream, HttpServletResponse response, String mimetype) throws Exception {

//Create a byte[] the same size as the exported ByteArrayInputStream.
byte[] buffer = new byte[byteArrayInputStream.available()];
int bytesRead = 0;

//Set response headers to indicate mime type and inline file.
response.reset();
response.setHeader("Content-disposition", "inline;filename=report.pdf");
response.setContentType(mimetype);

//Stream the byte array to the client.
while((bytesRead = byteArrayInputStream.read(buffer)) != -1) {
response.getOutputStream().write(buffer, 0, bytesRead);
}

//Flush and close the output stream.
response.getOutputStream().flush();
response.getOutputStream().close();

}


I think that the resp.getOutputStream().write is being stored in memory until the data can be sent through to the client. So the entire file might be read and stored in the resp.getOutputStream() causing memory issues and crashing!

I have tried Buffering these streams and also tried using Channels from java.nio, none of which seems to make any bit of difference to my memory issues. I have also flushed the outputstream once per iteration of the loop and after the loop, which didn't help.
8 years ago
Hi,
In my enterprise application I'm trying to generate a heavy PDF(around 800MB) and present to client for printing. The problem is that such a huge file is causing Websphere server to crash causing OutOfMemory Error.

Follwoing is the method which is returning the data to browser using response object.


* Utility method that demonstrates how to write an input stream to the server's local file system.
*/
private void writeToBrowser(ByteArrayInputStream byteArrayInputStream, HttpServletResponse response, String mimetype) throws Exception {

//Create a byte[] the same size as the exported ByteArrayInputStream.
byte[] buffer = new byte[byteArrayInputStream.available()];
int bytesRead = 0;

//Set response headers to indicate mime type and inline file.
response.reset();
response.setHeader("Content-disposition", "inline;filename=report.pdf");
response.setContentType(mimetype);

//Stream the byte array to the client.
while((bytesRead = byteArrayInputStream.read(buffer)) != -1) {
response.getOutputStream().write(buffer, 0, bytesRead);
}

//Flush and close the output stream.
response.getOutputStream().flush();
response.getOutputStream().close();

}


I think that the resp.getOutputStream().write is being stored in memory until the data can be sent through to the client. So the entire file might be read and stored in the resp.getOutputStream() causing memory issues and crashing!

I have tried Buffering these streams and also tried using Channels from java.nio, none of which seems to make any bit of difference to my memory issues. I have also flushed the outputstream once per iteration of the loop and after the loop, which didn't help.
8 years ago
Congrats Durgesh. Well Done.
Hi Caldwell,
I think I'll go with "OCMJEA", can't make it shorter than this. Although we can get rid of "M" but the word "Master" add weight to the title.
Thanks,
Anurag Narayan
Jonnabhatla/Nitin,
I used lots of books to prepare for various stages of the exam.


Part 1

a) SCEA 5 Study Guide by Mikalai Zaikin (http://java.boot.by/scea5-guide/).For me it was the

bible for part 1, although a few chapters were not written by him, but it is a very well

explained guide and sets up the base on which one can enhance the knowledge.

b) Sun certified Enterprise Architect for Java EE study guide,second edition by Mark Cade and

Humphrey Sheil


c) Head First Design Pattern for design patters and I studied various tutorials on net to

understand design patterns from various perspective.

d) SOA using java webservices by Mark D Hansen.
e) EJB 3 in action by Panda, Rahman and Lane.
f) Core J2EE patterns by Deepak Alur, john Crupi, Dan Malks.
g) For JSF I went through lots of tutorials available online.
h) For mock exams, I purchased Whizlabs mock exams, although the level of questions is not as

difficult as real exam but it helped me to time my approach and find out my weak areas.


Part 2 and 3
a) Sun certified Enterprise Architect for Java EE study guide,second edition by Mark Cade and

Humphrey Sheil.
9th chapter of this book is for part2. Whatever be your architecture your diagrams should be

on lines with diagrams presented in the example.Like it or not, Sun likes them that way.
For example your class diagram should be one diagram and not combination of various small

class diagrams and in deployment diagram various tiers should be displayed clearly.

b)For UML, I studied UML Distilled, Third Edition by Martin Fowler.
c) I also purchased Epractize lab's software for mock assignments. Although you should prepare diagrams based on how it is give on Humphry Sheil's book but this software can give you few assignments to practise on and also might give you some ideas on the approach/design patterns you can take.

I hope this list will be of use to you.

Thanks,
Anurag Narayan
Thanks everybody.

Hi Caldwell,
Do you have few suggestions about initials to put behind my name now?


Thanks,
Anurag
Hi Ranchers,
Just now I have received the mail from Oracle that I have passed the Sun Certified Java Architect for EE5 certification.

With very limited study material available in the market and looking at the difficulty level of exam, it would have been impossible for me to do it without Javaranch and fellow Ranchers.
I thank all the Ranchers who, even when I failed in first attempt,have helped and motivated me to carry on and succeed.

Thanks,
Anurag Narayan
Hi,
I failed SCEA part II in previous attempt and nowwill have to resubmit it. The vendor from whom I tried to purchase the exam told me that I will receive a new assignment and will have to work on it. It is not making sense to me as in process of resubmission now I don't have to appear for part III and part III is based on part II,so if my assignment will change then my part 3 answers also become baseless.Is soemone aware of current process?
Thanks,
Anurag
For your first question. Go to Annotation in Toolbox and select Rectangle from it. Click on the diagram and the tool will create a small rectangle. Drag it over the components you want to be in that tier.
Now, right click on the rectangle in the diagram and go to Format--> Alignment -->Send to back.It will put the rectangle in the background and all the components in foreground.
Hi,
Does anyone know the latest exact link to purchase CX-310-301R .
Oracle has sent me following 2 links and in both of them I could not find the link to purchase exam
1) www.ibt.prometric.com/sun
2) http://education.oracle.com
Everytime you ask them this question thay will send you a new link.

The link you see on sun's site is
http://in.sun.com/training/catalog/courses/CX-310-301R.xml which takes to payment screen and then you see server error on the screen(Can you believe it).

I'm not sure from where to buy this voucher now and also I don't want to end up paying money to some site which has been abandoned by Oracle now.
Thanks,
Anurag

Hi Sivakumar/Raj,
Thanks for your reply.My SSB, apart from talking to external system has business logic also and for that it uses supporting business logic POJO classes. I think it will not be appropriate to depict that a integration layer is using classes of business layer. I think I will add a POJO which will be a proxy to communicate with external system and this class will be in itegration layer and I will move SSB and it's supporting classes to business layer.
Thanks,
Anurag
Hi Sivakumar ,
Yes. It is a EJB(Stateless session Bean) which using JAX-WS talks directly to external system which hosts webservice.
I wanted to understand if I show a component diagram without integration layer and stateless session bean talking to webservice host, will it be a bad model or should I show JAX-WS as a component in integration layer?
Thanks,
Anurag
In my design the session bean interact with externl system using webservices(Java-WS), so what should I depict in integration tier, since session bean is part of business tier? Will it be ok to show session bean (business tier) directly connecting to external system and rule out integration layer altogether?
Thanks,
Anurag
Hi P Das,
Following are the comments and I don't read much into it.

"Marks lost in the class diagram due to incomplete and / or incorrect representation of the solution being put forward. Marks also lost in the component and deployment diagram for the same reason. "

I can see that with the marks I've got.Had they been more descriptive it would have helped.
Thanks,
Anurag
Thanks Kuppusamy. I think your advise of following diagrams in Humphry Sheil's book is good start