Same scenario as last time, but a cleaner solution: link a servlet directly from a JSP page and have the server serve the file as a response instead of a new JSP.
28/10/2013
[Java] BigInteger square root
Recently I was following a cryptography course and one assignment required us to compute square roots of very huge numbers. In Java, you require a BigInteger object to correctly represent numbers bigger than 231-1 (Integer max size).
Those BigInteger objects come with the basic operations implemented (addition, subtraction, multiplication and division) plus some other useful ones (exponentiation and modulus for example) but lack a method to compute the square root and it's highly unlikely that it will be added in the future[citation needed]. The only solution is either to implement your own method or find a reliable library.
21/10/2013
Kill Oracle RAC session from Toad
Toad versions previous than 11 accessing an Oracle database version prior to 11g, do not support killing sessions directly from the session browser, if the database being accessed is configured as a cluster.
As a workaround, aside from directly connecting to the desired instance, you may add to the tnsnames.ora file the TNS of the particular DB in the RAC from which you need to kill a session, then reload Toad.
As a workaround, aside from directly connecting to the desired instance, you may add to the tnsnames.ora file the TNS of the particular DB in the RAC from which you need to kill a session, then reload Toad.
[PL/SQL] Oracle continue loop with goto
Oracle database versions previous than 11g do not support the CONTINUE statement to skip to the end of a loop and keep cycling. As an alternative, you can use the GOTO statement WITH CAUTION.
Firstly, declare a label which marks the point were you want the execution to continue from using:
Firstly, declare a label which marks the point were you want the execution to continue from using:
<<label_name>>
and remember that the label must be followed by an executable statement; in practice, it means you cannot place it directly before the END LOOP instruction. Instead, follow it with a NULL statement as in:
<<label_name>>
NULL;
END LOOP;
Then simply skip to it as needed with:
GOTO label_name;
12/10/2013
[Java] Keep HTML form filled after failed Spring validation
I was working on a JSR-168 portlet written in Java 4 using Spring 2 and I had plain HTML forms validated via Spring validators. Everything works fine with this setting but upon failed validation, the page would reload showing the errors and an empty form.
Instead of replacing all the forms with Spring ones (form:form), I found an alternative solution which let me keep my current project structure and tone down the necessary modifications.
08/10/2013
[Java] Store session attributes in portlet controller and retrieve them from JSP
I was coding a portlet following the JSR-168 specification and Spring 2 and I noticed an inconsistent behaviour on some pages. Passing some Map objects, needed to initialize the JSP drop-down menus, by storing them in session in the controller and retrieving them in the JSP, would work always except when the page was reloaded after a failed form validation during the submission phase.
Note: this issue could not be solved by simply using the ModelAndView addObject("name", value) method in the controller and then retrieving the object in the JSP with ${name} outside of a Java block, since I needed to perform some actions on those values directly from the JSP, therefore inside a Java block, without using EL.
Subscribe to:
Posts (Atom)