Forums Register Login
About Servlet get attribute
JSP use JSTL <sql> generate result, then call Servlet to process generate Excel file.

But I got Null in Servlet...
I don't know how to setAttribute then Servlet can use the result.



JSTL's Sql tags are not really meant to be mixed with real back end code this way. They were designed for trivial apps like prototypes or small utilities.

You'd be better off moving your database access code to plain old Java objects that can be instanciated from your servlets in the first place.

From the JSTL Spec (prelude to chapter 10):

Many web applications need to access relational databases as the source of dynamic
data for their presentation layer. While it is generally preferred to have database
operations handled within the business logic of a web application designed with an
MVC architecture, there are situations where page authors require this capability
within their JSP pages (e.g. prototyping/testing, small scale/simple applications,
lack of developer resources).

The JSTL SQL actions provide the basic capabilities to easily interact with relational

[ January 15, 2008: Message edited by: Ben Souther ]
Can you shoot lasers out of your eyes? Don't look at this tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database

This thread has been viewed 1813 times.

All times above are in ranch (not your local) time.
The current ranch time is
Mar 24, 2019 21:22:00.