Monday, April 20, 2020

How to run javascript inside a JSP scriplet


By writing your js code within <script></script> tag inside out.println() has shown below:

<%
    if( a > 9)
   {

         out.println("<script>document.getElementById('rd"+(a+1)+"').disabled=true;</script>");

   }

%>







How to comment JSP code


<%-- This is a JSP comment and will be completely ignored by the JSP compiler --%>

How to disable a option in a set of radio buttons

<input type="radio" name="disableme" id="1"> Animal
<input type="radio" name="disableme" id="2"> Mammal <input type="radio" name="disableme" id="3"> Human
document.getElementById("1").disabled = true;

source:

 https://www.w3schools.com/jsref/prop_radio_disabled.asp

https://stackoverflow.com/questions/13245672/how-to-disable-the-radio-button-using-javascript-not-using-any-js-framework

Thursday, April 16, 2020

Subnet works - CIDR notation

JDBC: Check if the record exists in the database


Assuming you are working with a newly returned ResultSet whose cursor is pointing before the first row, an easier way to check this is to just call isBeforeFirst(). This avoids having to back-track if the data is to be read.

if (!resultSet.isBeforeFirst() ) {   
   
System.out.println("No data"); } else{ while(resultSet.next()){ resultSet.getString(1);       resultSet.getString(1); …. ….       resultSet.getString(n); } } source: https://stackoverflow.com/questions/867194/java-resultset-how-to-check-if-there-are-any-results

Wednesday, April 15, 2020

Java enums

Let us see another example of Java enum where we are using value(), valueOf(), and ordinal() methods of Java enum.
  1. class EnumExample1{  
  2. //defining enum within class  
  3. public enum Season { WINTER, SPRING, SUMMER, FALL }  
  4. //creating the main method  
  5. public static void main(String[] args) {  
  6. //printing all enum  
  7. for (Season s : Season.values()){  
  8. System.out.println(s);  
  9. }  
  10. System.out.println("Value of WINTER is: "+Season.valueOf("WINTER"));  
  11. System.out.println("Index of WINTER is: "+Season.valueOf("WINTER").ordinal());  
  12. System.out.println("Index of SUMMER is: "+Season.valueOf("SUMMER").ordinal());  
  13.   
  14. }}  
Output:
WINTER
SPRING
SUMMER
FALL
Value of WINTER is: WINTER
Index of WINTER is: 0
Index of SUMMER is: 2

source: https://www.javatpoint.com/enum-in-java

Sacred Thought

28 April 2024 Today I am going to explain verse 31 - 38 chapter two for you all. There is no opportunity better than a righteous war (सत्य औ...