Update an HTML Form Using an XML ActiveX Object and a Servlet

Update an HTML Form Using an XML ActiveX Object and a Servlet

The minimum requirement for this tip to work is to have Internet Explorer with MSXML objects installed when Windows is installed. The DOMDocument is also available in the new versions of Netscape. This example displays user information based on the login id without submitting the form.

Create a servlet that will submit an .xml document based on the request parameter “login” value:

import javax.servlet.*;import javax.servlet.http.*;import java.io.*;public class UserInfoServlet    extends HttpServlet {  private static final String CONTENT_TYPE = "text/xml";  //Process the HTTP Get request  public void doGet(HttpServletRequest request, HttpServletResponse response) throws      ServletException, IOException {    doPost(request, response);  }  //Process the HTTP Post request  public void doPost(HttpServletRequest request, HttpServletResponse response) throws      ServletException, IOException {    String login = request.getParameter("login");    String info = null;    if (login != null && "guest".equalsIgnoreCase(login)) {      info = "Guest";    }    else {      info = "Unknown";    }    response.setContentType(CONTENT_TYPE);    PrintWriter out = response.getWriter();    out.println("");    out.println("");    out.println(info);    out.println("");  }}

Add servlet mapping for this servlet in the web.xml file as follows:

  userinfo  UserInfoServlet  userinfo  /ui

Following is the HTML page:

  User Information      
Enter Login Id: User Information: (Readonly)

Now, if you type “guest” in the login input, “Guest” or otherwise Unknown will be displayed automatically.

Share the Post:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several

data fivetran pricing

Fivetran Pricing Explained

One of the biggest trends of the 21st century is the massive surge in analytics. Analytics is the process of utilizing data to drive future decision-making. With so much of

kubernetes logging

Kubernetes Logging: What You Need to Know

Kubernetes from Google is one of the most popular open-source and free container management solutions made to make managing and deploying applications easier. It has a solid architecture that makes