Found 9326 Articles for Object Oriented Programming

What are the standard attributes that should be passed to a custom tag in a JSP page?

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

48 Views

Consider including the following properties for an attribute −S.No.Property & Purpose1nameThe name element defines the name of an attribute. Each attribute name must be unique for a particular tag.2requiredThis specifies if this attribute is required or is an optional one. It would be false for optional.3rtexprvalueDeclares if a runtime expression value for a tag attribute is valid4typeDefines the Java class-type of this attribute. By default, it is assumed as String5descriptionInformational description can be provided.6fragmentDeclares if this attribute value should be treated as a JspFragment.Following is the example to specify properties related to an attribute −.....           ... Read More

How can I create custom tag in JSP which can accept attribute from parent jsp page?

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

175 Views

You can use various attributes along with your custom tags. To accept an attribute value, a custom tag class needs to implement the setter methods, identical to the JavaBean setter methods as shown below −package com.tutorialspoint; import javax.servlet.jsp.tagext.*; import javax.servlet.jsp.*; import java.io.*; public class HelloTag extends SimpleTagSupport {    private String message;    public void setMessage(String msg) {       this.message = msg;    }    StringWriter sw = new StringWriter();    public void doTag()    throws JspException, IOException {       if (message != null) {          /* Use message from attribute ... Read More

I want to create a custom tag in JSP. How to write a custom tag in JSP?

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

151 Views

A custom tag is a user-defined JSP language element. When a JSP page containing a custom tag is translated into a servlet, the tag is converted to operations on an object called a tag handler. The Web container then invokes those operations when the JSP page's servlet is executed.JSP tag extensions let you create new tags that you can insert directly into a JavaServer Page. The JSP 2.0 specification introduced the Simple Tag Handlers for writing these custom tags.To write a custom tag, you can simply extend the SimpleTagSupport class and override the doTag() method, where you can place your ... Read More

Please share one example of using taglib directive in JSP

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

58 Views

The JavaServer Pages API allow you to define custom JSP tags that look like HTML or XML tags and a tag library is a set of user-defined tags that implement custom behavior.The taglib directive declares that your JSP page uses a set of custom tags, identifies the location of the library, and provides means for identifying the custom tags in your JSP page.The taglib directive follows the syntax given below −Where, the uri attribute value resolves to a location the container understands and the prefix attribute informs a container what bits of markup are custom actions.You can write the XML ... Read More

How to read form data using JSP via GET Method?

George John
Updated on 30-Jul-2019 22:30:25

388 Views

Following is an example that passes two values using the HTML FORM and the submit button. We are going to use the same JSP main.jsp to handle this input.                    First Name:                    Last Name:                     Keep this HTML in a file Hello.htm and put it in /webapps/ROOT directory. When you would access http://localhost:8080/Hello.htm, you will receive the following output.First Name: Last Name:   Try to enter the First Name and ... Read More

How to read request parameters passed in URL using JSP?

Chandu yadav
Updated on 30-Jul-2019 22:30:25

3K+ Views

The following URL will pass two values to HelloForm program using the GET method.href="http://localhost:8080/main.jsp?first_name=ZARA&last_name=ALI" Below is the main.jsp JSP program to handle input given by web browser. We are going to use the getParameter() method which makes it very easy to access the passed information −           Using GET Method to Read Form Data               Using GET Method to Read Form Data                First Name:                                  Last ... Read More

What is a taglib directive in JSP?

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

103 Views

The JavaServer Pages API allow you to define custom JSP tags that look like HTML or XML tags and a tag library is a set of user-defined tags that implement custom behavior.The taglib directive declares that your JSP page uses a set of custom tags, identifies the location of the library, and provides means for identifying the custom tags in your JSP page.The taglib directive follows the syntax given below −Here, the uri attribute value resolves to a location the container understands and the prefix attribute informs a container what bits of markup are custom actions.You can write the XML ... Read More

How to read form data using JSP?

Arjun Thakur
Updated on 30-Jul-2019 22:30:25

2K+ Views

JSP handles requests using getParameter() method to read simple parameters and getInputStream() method to read binary data stream coming from the client.Reading Form Data using JSPJSP handles form data parsing automatically using the following methods depending on the situation −getParameter(): You call request.getParameter() method to get the value of a form parameter.getParameterValues(): Call this method if the parameter appears more than once and returns multiple values, for example, checkbox.getParameterNames(): Call this method if you want a complete list of all parameters in the current request.getInputStream(): Call this method to read binary data stream coming from the client.Read More

What is difference between GET and POST method in HTTP protocol?

Ankith Reddy
Updated on 30-Jul-2019 22:30:25

379 Views

GET methodThe GET method sends the encoded user information appended to the page request. The page and the encoded information are separated by the ? character as follows −http://www.test.com/hello?key1=value1&key2=value2The GET method is the default method to pass information from the browser to the web server and it produces a long string that appears in your browser's Location:box. It is recommended that the GET method is better not used. if you have a password or other sensitive information to pass to the server.The GET method has size limitation: only 1024 characters can be in a request string.This information is passed using ... Read More

Please share a running example of include directive in JSP

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

50 Views

The include directive is used to include a file during the translation phase. This directive tells the container to merge the content of other external files with the current JSP during the translation phase. You may code include directives anywhere in your JSP page.The general usage form of this directive is as follows −The filename in the include directive is actually a relative URL. If you just specify a filename with no associated path, the JSP compiler assumes that the file is in the same directory as your JSP.You can write the XML equivalent of the above syntax as follows ... Read More

Advertisements