Sree Lakshmi Sugunan

Greenhorn
+ Follow
since Feb 29, 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 Sree Lakshmi Sugunan

Hi,

I am writing contents from a servlet to outputstream with content type as excel. The excel is opened in another window. The excel comes fine. The issue is the images in the excel in not dispayed.

The content I write to the stream is html with xml(that uses excel schema). So the image is represented as <img src="">. The issue seems that since it is open in another window, it is not getting the access to the image file kept inside the application that has a login.

Is there anyway I can display the image in another window itself. Will encodeURL() help. I tried that but still it is not helping. I am not sure if I am using it correctly.
13 years ago
Hi,

I have a common template jsp. From this I do static include of header footer jsps and then do dynamic include the jsp that will be the changing part. Will I be able to access the title of the dynamically included jsp in the common template.jsp. I need to set it in a header. I dont wnat to change the jsps that is dynamically included. Will I get any refernce to the title?
14 years ago
JSP
Hi,

Finally one solution seems to work. Instead of reloading the url using window.location.reload(), I am submitting the form on load of the intermediate jsp, this brings the report in correct format.

In order to handle the back button issue because of a new request due to submit, I give the submit of form to the same url. So it will be considered as refresh by the browser. At the handler side, I handle he logic based on if req is coming for first or second time.

I have to do a lot of testing to confirm this. This doesnt seems to be a good way of doing but dont have any other option.

Thank you very much for the help. The url reload idea lead to this solution. Will be letting you know the result soon.
14 years ago
JSP
Hi,

Thanks for the reply, I have changed the same but that doesnt bring any effect.

The issue is the pdf content is not recoginized by the browser as pdf. The browser displays as below. That means it is taking ti as text and not pdf.

If I send the request directly to handler instead of refresh, the pdf is shown correctly, so the header are fine I guess. Is it because of the refresh and the previous page was text this time also browser thinks it to be text. I dont get any message about the content type has been reset or something.


[ UD: added line breaks ]
[ August 15, 2008: Message edited by: Ulf Dittmer ]
14 years ago
JSP
Hi,

I am doing this in a servlet (handler)only. Also this works fine, if I direct the request directly to this handler. If the request is a window.location.reload(true), then only the issue happens.

Currently from the submit jsp(J1)(where user selects the select report), it goes to the handler(H1), where it gets the report from SAS.So if the report type is pdf or excel, we forward to temporary jsp, which has the scripts added and run and onload of this page the reload() is called for the same handler(H1)(to avoid the back url issue). In the handler, I see if the req has any hidden value set, if set, it is directed to report displaying handler(H2) that has the code given in the previous reply.

So I dont get it why does it displays it as text.

If I directly forward the req on submit(J1) to H2, the report is displayed as pdf . So is it because it is like a refresh.

Can we do something that the browser comes to know it is pdf
14 years ago
JSP
Hi,

I cannot try the file as link, as I must not change the current design.

Currently I am trying what Ulf Dittmer suggested. I show a jsp that will run the script(with a message like your report is generated). Onload of the page I set the url to the handler. But here also I am having issues.

window.location.replace().This is supposed to rewrite the current docuemnt link in the history also. but this doesnt happens, so when I click browser back after opening the pdf(opening works fine), it brings me back to the script running jsp.(eventhough replace needs to overwrite that link from history).

So I tried to submit to the same link again and in the servlet side I am checking if it is a second refresh(setting variable in session and removing it), go to handler to write the pdf stream,now pdf is considered as text by the browser and the pdf is directly writen to page as text inspite of my setting the res.setContentType("application/pdf").


I have removed the meta header from the reloading jsp still no effect. Since it is a refresh, does the browser consider the content type as that of the old.

Can you please help me on this...

Thanks
Sree Lakshmi
14 years ago
JSP
Hi,

Can I use Frameset to have to part one with content type as html/text and the other to have content type as pdf
14 years ago
JSP
Hi,

Since no one has replied back, I think there is a confusion about the issue I am having now. So putting it below:

This is currently what I try to do.

I have a parent submit jsp from where I submit to a servlet(to generate a report). From this servlet if the report type is pdf(content type is pdf), I forward to a intermediate jsp. The purpose of this jsp is to set certain headers and add the javascript content to html(this isto create a webtrend log req an image to server onload of page.). After running this script, I forward it to another servlet to write back the pdf response.

The issue is I cant write to the client before the forward. So I thought of opening a new explorer using a script and run the add javascript through that browser so that the intermediate jsp can go ahead with the forward.

First of all I am not sure if this works because when I try, I invoke the script onload but the control goes to the servlet with the forward and doesnt reach the script. If forward is there cant we do any thing else in the page to send to client
14 years ago
JSP
Hi,

In between I had put another post "javascript and jsp forward" from where I was redirected here. The one I have mentioned in this post is my current issue.
14 years ago
JSP
Hi,

I had thought of this but if invole the post request using java.net.URL, I wont be able to set certain headers. The javascript that webtrend (vendor provided) gives sets lot of information based on cookies and details of the browser or client. So I will not be able to set that details from the servlet part right. That is why I moved to the jsp solution.
14 years ago
JSP
Hi

I am sorry for the wrong description. The forward is to another servlet only. I have a parent submit jsp from where I submit to a servlet(to generate a report). From this servlet if the report type is pdf(content type is pdf), I forward to a intermediate jsp. The purpose of this jsp is to set certain headers and add the javascript content to html(this isto create a webtrend log req an image to server onload of page.). After running this script, I forward it to another servlet to write back the pdf response.

The issue is I cant write to the client before the forward. So I thought of opening a new explorer using a script and run the add javascript through that browser so that the intermediate jsp can go ahead with the forward.

First of all I am not sure if this works because when I try, I invoke the script onload but the control goes to the servlet with the forward and doesnt reach the script. If forward is there cant we do any thing else in the page to send to client


I had another post also for a another issue of this problem (Generate PDF report from jsp) which has more details of the issue.

Thanks in Advance
14 years ago
JSP
Hi,

From a jsp page I need to forward to another page. Also I need to open another window using the function window.open

called from a javascript func

function popup()
{

window.open("<%=url%>", "tinyWindow", "toolbar=1,width=150,height=100");
}

Will I be able to acheive both?

I am calling the script on load but by that time the forward is already done and control doesnt goes to the script. Is there a way to run both? There is no restriction on when the script can be run. Any time is ok. But I dont get any funtions that run the script before the load of the page.


I put the jspforward inside the script, the forward happens but the window doesnt open.
14 years ago
JSP
Hi,

I didnt want a call to go again to the server side. But it seems I dont have a choice. Thanks a lot for the reply.
14 years ago
JSP
Hi,

Thank you. I will ellaborate on the issue I am having. From the server I get the pdf contents as binary stream. I could have directly written it outputstream to get the pdf. (This work fine also).

But I have an additional requirment that I need to log the details of the pdf (like name user etc) . This I have to do using Webtrend. They give us some javascript fucntions that sets certain varaibles onload of a jsp and then request for an image to the logging server(Webtrend). This passes all the details to the server.

Since I cant send the script along with the pdf sicne content type is pdf(wont be detected) what I am doing is forwarding the request to a jsp so that the script is run. Now in the session i had keep the contents of binary stream. From the jsp, can I use this binary stream to open a PDF with a dialouge box open read etc.
14 years ago
JSP
Hi,
I had been checking if there is an option to do so. In some pages I have seen I cant do this from a jsp. I want to know abt if this is possible.
14 years ago
JSP