JSP Section Index
What is the difference between RequestDispatcher's forward(ServletRequest request, ServletResponse response) method and HttpServletResponse's sendRedirect(String location) method?
What is the difference between RequestDispatcher's forward(ServletRequest request, ServletResponse response) method and HttpServletResponse's sendRedirect(String location) method?
I want to run JSP files using the Tomcat server, where should I place my JSP files?
I want to run JSP files using the Tomcat server, where should I place my JSP files?
How can I print the stack trace of an Exception out to my JSP page?
How can I print the stack trace of an Exception out to my JSP page?
How can I serve Word/Excel documents to a web client from JSP's and/or servlets?
How can I serve Word/Excel documents to a web client from JSP's and/or servlets?
I am writing a simple jsp to retrieve and save from/to my MySQL db. My retrieve and save functions work great. Now, depending on the action in the browser, I would only like to invoke one of the methods. For example, for the onChange event, I would like to get the info from the db. For the onClick event, I would like to save the info to the db. Considering these actions are on the client side and jsp is on the server side, is there a way to do this? If not, does anyone have a suggestion on how this can be done?
I am writing a simple jsp to retrieve and save from/to my MySQL db. My retrieve and save functions work great. Now, depending on the action in the browser, I would only like to invoke one of the m...more
How can I design my servlet/JSP so that query results get displayed on several pages, like the results of a search engine? Each page should display, say, 10 records each and when the next link is clicked, I should see the next/previous 10 records and so on.
Use a Java Bean to store the entire result of the search that you have found. The servlet will then set a pointer to the first line to be displayed in the page and the number of line...more
How can I display content in the form of a Tree using JSP?
There are a few ways that you could try, although it all depends on any restrictions you have on deployment.
First off, you could use Swing's JTree in a small applet. This would require the use o...more
How can I precompile all my JSP files when I place them on my web site? I don't want to wait until they are hit the first time.
Release 3.1 of the Jakarata Tomcat JSP server (found at jakarta.apache.org)
includes a JSP compiler (JSPC) that does exactly this. You can specify either
a web application directory or a specif...more
Is there any way in JSP to set focus on an input field in a HTML form using JSP code, and not JavaScript?
No, there isn't. Remember, JSP is strictly a server-side technology, which is responsible
for generating dynamic content in HTML, DHTML or XML format. Setting focus on
specific input elements wi...more
How can you copy a JavaScript variable to a JSP session variable without using cookies?
How can you copy a JavaScript variable to a JSP session variable without using cookies?
I am trying to store the value of a SELECT object in a session variable so it can be accessed in other JSP's...more
How do I download a (binary, text, executable) file from a servlet or JSP?
Solution 1: Just use HTTP! This has nothing to do with servlets per se. Make sure the file is on your web server. Then you can either embed a link for your user to click, as
<a href="run...more
How do I perform browser redirection from a JSP page?
You can use the response implicit object to redirect the browser to a different resource, as:
response.sendRedirect("http://www.foo.com/path/error.html");
You can also physically alter
the Loc...more
How do I use comments within a JSP page?
You can use "JSP-style" comments to selectively block out code while debugging
or simply to comment your scriptlets. JSP comments are not visible at the client.
For example:
<%-- the script...more
Can a JSP page process HTML FORM data?
Yes. However, unlike servlets, you are not required to implement HTTP-protocol specific
methods like doGet() or doPost() within your JSP page. You can obtain the data for the
FORM input elements...more
How do I upload a file to my servlet or JSP?
On the client side, the client's browser must support form-based
upload. Most modern browsers do, but there's no guarantee. For
example,
<FORM ENCTYPE='multipart/form-data'
method='POST' ...more