tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From (Alex Chaffee)
Subject [FAQ] jGuru FAQ Update
Date Sat, 01 Sep 2001 00:22:33 GMT
jGuru maintains FAQs and Forums on Servlets, JSP, and Tomcat (as well as
many other Java topics).  Here is an automated update on recent postings to
Tomcat-related FAQs.  Please direct flames and feedback to .

 - Alex

SPONSORED BY developerWorks

need it? get it. tools, code and tutorials for open-standards based development.

Stay informed with dW's weekly email newsletter

Hi.  You asked to be notified weekly when certain items get new entries.

You can shut email notification off at the FAQ home
page(s) or:

++ JavaServer Pages (JSP) FAQ:

I need to trap all kinds 500 error on my jsp page. I have tried the <%@ page errorPage="myerror.jsp">
but it only works on selected errors. How can I trap all errors, including syntax errors?

Does anyone know how I could display an rtf string from JSP? I have resumes stored in a database
and want to display them in a browser.

Does anyone know how I could display an rtf string from JSP? I have resumes stored in a database
and want to display them in a browser.

How can I create complex, pretty reports which can be printed at the client from JSP?

I know I can get JP tag attributes with setXXX() method but I want to know if  it is possible
to modify attribute values within a tag handler.
For example:<br>
I want to do iterator tag that iterates  over a list and at each iteation it can assign the
current iterated value to one of its attributes and cause the JSP page to display different
values at each iteration.
Is there any way to do this?

Is it possible to view which web server or servlet engine is used: IIS, iPlanet etc. on a
JSP page? Just like System.getProperty( for the operating system?

How do I stop a JSP based download adding a newline to the first character of a file?
I am using JSP to set a Content-Disposition in order to keep IE from automatically opening
Excel/Word/Acrobat/etc when it sees a file type it recognizes.  However, when I use ServletOutputStream
to do this, for some reason I end up with a newline (ASCII hex 0A) character at the beginning
of my file (I discovered this with a hex editor). This causes Word and Excel to blow up when
I try to open the files because they can't cope with the extra character. (I am using the
ATG Dynamo Application Server and am hoping this is not an artifact of the implementation.)
This is what my JSP looks like:
// fname is the file name
File f = new File(fname);
InputStream in = new FileInputStream(f);
ServletOutputStream outs = response.getOutputStream();
int bufferSize = 4096;
byte[] ioBuffer = new byte[bufferSize];
byte[] lastBuffer; // last buffer
long counter = 0; // how many bytes we have gotten through
long fileSize = f.length();

response.setHeader("Content-Disposition", "attachment;filename=" + shortname);

// in a big file, use big buffer chunks
while (fileSize &gt; (counter + bufferSize))
           counter += bufferSize;
// add final chunk if the fileSize does not happen to be divisible by the bufferSize
if (fileSize &gt; counter)
	lastBuffer = new byte[ (int) (fileSize - counter) ];;
I also tried to do this:
String headers = "Content-Disposition:attachment;filename=" + shortname + "\r\n" +
		 "Content-Type: application/download\r\n\r\n";
in place of the setHeader() and setContentType() but I end up just opening a webpage with
that string followed by the bytes from the file I want downloaded.

++ Servlets FAQ:

Are there any restrictions placed on applets loaded from HTML pages generated from servlets
/ JSP pages?

View raw message