JSP Articles

Page 6 of 8

What are important server response headers that are useful in web programming?

Arjun Thakur
Arjun Thakur
Updated on 30-Jul-2019 218 Views

Following is a summary of the most useful HTTP 1.1 response headers which go back to the browser from the web server. These headers are frequently used in web programming −Sr.No.Header & Description1AllowThis header specifies the request methods (GET, POST, etc.) that the server supports.2Cache-ControlThis header specifies the circumstances in which the response document can safely be cached. It can have values public, private or no-cache etc. Public means document is cacheable, Private means document is for a single user and can only be stored in private (nonshared) caches and no-cache means document should never be cached.3ConnectionThis header instructs the ...

Read More

How to send an error code using JSP to browser?

George John
George John
Updated on 30-Jul-2019 466 Views

Following example shows how a 407 error code is sent to the client browser. After this, the browser would show you "Need authentication!!!" message.           Setting HTTP Status Code     You will receive the following output −HTTP Status 407 - Need authentication!!! type Status report message Need authentication!!! description The client must first authenticate itself with the proxy (Need authentication!!!). Apache Tomcat/5.5.29

Read More

What is import attribute in JSP?

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jul-2019 2K+ Views

The import attribute serves the same function as and behaves like, the Java import statement. The value for the import option is the name of the package you want to import.To import java.sql.*, use the following page directive −To import multiple packages, you can specify them separated by comma as follows −By default, a container automatically imports java.lang.*, javax.servlet.*, javax.servlet.jsp.*, and javax.servlet.http.*.

Read More

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

Ankith Reddy
Ankith Reddy
Updated on 30-Jul-2019 660 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

How to read form data using JSP?

Arjun Thakur
Arjun Thakur
Updated on 30-Jul-2019 3K+ 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

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

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jul-2019 277 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

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

Samual Sam
Samual Sam
Updated on 30-Jul-2019 111 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 to pass check boxes data using JSP?

Arjun Thakur
Arjun Thakur
Updated on 30-Jul-2019 4K+ Views

Checkboxes are used when more than one option is required to be selected.Following is an example HTML code, CheckBox.htm, for a form with two checkboxes.                     Maths           Physics           Chemistry                     The above code will generate the following result − Maths  Physics  Chemistry Following is main.jsp JSP program to handle the input given by the web browser for the checkbox button.           Reading Checkbox Data               Reading Checkbox Data                Maths Flag:                                  Physics Flag:                                  Chemistry Flag:                               The above program will generate the following result −Reading Checkbox DataMaths Flag :: onPhysics Flag:: nullChemistry Flag:: on

Read More

How to use a filter in JSP?

Ankith Reddy
Ankith Reddy
Updated on 30-Jul-2019 752 Views

Following example shows how to print the client's IP address and the current date time, each time it would access any JSP file. This example will give you a basic understanding of the JSP Filter, but you can write more sophisticated filter applications using the same concept −// Import required java libraries import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import java.util.*; // Implements Filter class public class LogFilter implements Filter {    public void init(FilterConfig config) throws ServletException {       // Get init parameter       String testParam = config.getInitParameter("test-param");       //Print the init parameter ...

Read More

How do you define multiple filters in JSP?

Arjun Thakur
Arjun Thakur
Updated on 30-Jul-2019 841 Views

Your web application may define several different filters with a specific purpose. Consider, you define two filters AuthenFilter and LogFilter. Rest of the process will remain as explained above except you need to create a different mapping as mentioned below −    LogFilter    LogFilter           test-param       Initialization Paramter        AuthenFilter    AuthenFilter           test-param       Initialization Paramter        LogFilter    /* AuthenFilter /* Filters Application OrderThe order of filter-mapping elements ...

Read More
Showing 51–60 of 77 articles
« Prev 1 4 5 6 7 8 Next »
Advertisements