Found 7442 Articles for Java

How to check if an input string contains a specified substring in JSP?

Samual Sam
Updated on 30-Jul-2019 22:30:25

3K+ Views

The fn:contains() function determines whether an input string contains a specified substring.SyntaxThe fn:contains() function has the following syntax −boolean contains(java.lang.String, java.lang.String)ExampleFollowing example explains the functionality of fn:contains() function −           Using JSTL Functions     Found test string Found TEST string You will receive the following result −Found test string

How to apply XSL transformation on an XML document?

Samual Sam
Updated on 30-Jul-2019 22:30:25

512 Views

The tag applies an XSL transformation on an XML document.AttributeThe tag has the following attributes −AttributeDescriptionRequiredDefaultdocSource XML document for the XSLT transformationNoBodydocSystemIdURI of the original XML documentNoNonexsltXSLT stylesheet providing transformation instructionsYesNonexsltSystemIdURI of the original XSLT documentNoNoneresultResult object to accept the transformation's resultNoPrint to pagevarVariable that is set to the transformed XML documentNoPrint to pagescopeScope of the variable to expose the transformation's resultNoNoneExampleConsider the following XSLT stylesheet style.xsl −                                                                                                                                                                                                                                                                     Now consider the following JSP file −           JSTL x:transform Tags               Books Info:                                                 Padam History                 ZARA                 100                                             Great Mistry                 NUHA                 2000                                 You will receive the following result −Books InfoPadam HistoryZARA100Great MistryNUHA2000

Can we have a switch statement in JSP for XPath expression?

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

423 Views

The tag works like a Java switch statement. With this, you can choose between a number of alternatives. Where the switch statement has the case statements, the tag has the tags. In a similar way, a switch statement has the default clause to specify a default action and the tag has the tag as the default clause.AttributeThe tag does not have any attribute.The tag has one attributes which is listed below.The tag does not have any attribute.The tag has the following attributes −AttributeDescriptionRequiredDefaultselectCondition to evaluateYesNoneExample         ... Read More

How to handle Exceptions while working with JDBC applications?

Daniol Thomas
Updated on 30-Jul-2019 22:30:25

218 Views

Whenever a JDBC application encounters an issue while executing SQL statements an SQLException is thrown.This class provides information on the errors that occur while interacting with the database.Following are the main methods of the SQLException class:Sr.NoMethod & Description1int getErrorCode()This method returns the exception code for the Exception occurred.2SQLException setNextException(SQLException ex)Using this method you can create a chain of exceptions by adding a new exception to the current exception.3String getSQLState()This method returns the SQLState of the current exception.4Iterator iterator()This method returns an iterator to iterate through the chain of SQLExceptions.5void getNextException(SQLException ex)This method is used to retrieve next SQLException in this ... Read More

How to iterate over nodes of XML in JSP?

Samual Sam
Updated on 30-Jul-2019 22:30:25

468 Views

The tag is used to loop over nodes in an XML document.AttributeThe tag has the following attributes −AttributeDescriptionRequiredDefaultselectThe XPath expression to be evaluatedYesNonevarName of the variable to store the current item for each loopNoNonebeginThe start index for the iterationNoNoneendThe end index for the iterationNoNonestepThe size of the index increment while iterating over the collectionNoNonevarStatusThe name of the variable in which the status of the iteration is storedNoNoneExampleThe following example shows the use of the tag −           JSTL x:if Tags               Books Info:     ... Read More

Can we test XPath expression in JSP?

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

254 Views

The tag evaluates a test XPath expression and if it is true, it processes its body. If the test condition is false, the body is ignored.AttributeThe tag has the following attributes −AttributeDescriptionRequiredDefaultselectThe XPath expression to be evaluatedYesNonevarName of the variable to store the condition's resultNoNonescopeScope of the variable specified in the var attributeNoPageExampleFollowing is an example that show the use of the tag −           JSTL x:if Tags               Books Info:                           ... Read More

What is RowId object in JDBC Explain?

Daniol Thomas
Updated on 30-Jul-2019 22:30:25

647 Views

A RowId is a built-in type of SQL which is an address of a row in a table of a database. The RowId interface of the java.sql package maps with the SQL ROWID value.RowId values are unique for every row and they are the fastest way to access a row. You cannot use this as a primary key of a table.Retrieving RowId objectsYou can retrieve the RowId of a particular row using the getRowId() method of the ResultSet, CallableStatement, PreparedStatement interfaces.This method accepts a String value representing a column label or, an integer value representing the column index and returns ... Read More

How to use a value of XPath expression result in JSP in a variable?

Samual Sam
Updated on 30-Jul-2019 22:30:25

224 Views

The tag sets a variable to the value of an XPath expression.If the XPath expression results in a boolean, tag sets a java.lang.Boolean object; for a string, java.lang.String; and for a number, java.lang.Number.AttributeThe tag has the following attributes −AttributeDescriptionRequiredDefaultvarA variable that is set to the value of the XPath expressionYesBodyselectThe XPath expression to be evaluatedNoNonescopeScope of the variable specified in the var attributeNoPageExampleFollowing example will show how to use the tag −           JSTL Tags               Books Info:           ... Read More

How to process SQL statements with JDBC explain with an example?

Daniol Thomas
Updated on 30-Jul-2019 22:30:25

6K+ Views

To process an SQL statement, you need to follow the steps given below:Establish the connection.Create a statement.Execute the statement/query.Process the result.Close the connection.Establishing a ConnectionTo process SQL statements first of all you need to establish connection with the desired DBMS or, file System or, other data sources.To do so, Register the JDBC driver class, corresponding to the DataSource you need to the DriverManager using the registerDriver() method.Driver myDriver = new com.mysql.jdbc.Driver(); DriverManager.registerDriver(myDriver);This method accepts an object of the Driver class; it registers the specified Driver with the DriverManager.You can also register the driver using the forName() method. This method loads ... Read More

How to print XPath Expression result in JSP?

Samual Sam
Updated on 30-Jul-2019 22:30:25

380 Views

The tag displays the result of an XPath expression. It functions the same as JSP syntax.AttributeThe tag has the following attributes −AttributeDescriptionRequiredDefaultselectXPath expression to evaluate as a string, often using XPath variablesYesNoneescapeXmlTrue if the tag should escape special XML charactersNotrueExampleLet us take an example which will cover the tags (a) , (b) .           JSTL x:out Tags               Books Info:                                                 ... Read More

Advertisements