Share on Google+Share on Google+

prashanthi
servlets deploying
2 Answer(s)      8 years ago
Posted in : Java Beginners

Ads

View Answers

June 3, 2008 at 6:50 PM


Hi friend,

package javacode;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.*;

public class ServletDeploy extends HttpServlet {
public void doGet( HttpServletRequest request, HttpServletResponse response )
throws IOException, ServletException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head>");
out.println("<title>Deploy Servlet Example</title>");
out.println("</head>");
out.println("<body>");
out.println("<h3>HTTP Request Header</h3>");
out.println("<table border='1'>");
out.println(" <tr bgcolor=pink>");
out.println(" <td><b>Name</b></td>");
out.println(" <td><b>Value</b></td>");
out.println(" </tr>");
Enumeration e = request.getHeaderNames();
while (e.hasMoreElements()){
String name = (String)e.nextElement();
String value = request.getHeader(name);
out.println(" <tr>");
out.println(" <td bgcolor=pink>"+name+"</td>");
out.println(" <td>"+value+"</td>");
out.println(" </tr>");
}
out.println("</table>");
out.println("<h3>HTTP Request Information</h3>");
out.println("<table border='1'>");
out.println(" <tr bgcolor=pink>");
out.println(" <td><b>Name</b></td>");
out.println(" <td><b>Value</b></td>");
out.println(" </tr>");
out.println(" <tr>");
out.println(" <td bgcolor=pink>Method:</td>");
out.println(" <td>"+request.getMethod()+"</td>");
out.println(" </tr>");
out.println(" <tr>");
out.println(" <td bgcolor=pink>Request URI:</td>");
out.println(" <td>"+request.getRequestURI()+"</td>");
out.println(" </tr>");
out.println(" <tr>");
out.println(" <td bgcolor=pink>Protocol:</td>");
out.println(" <td>"+request.getProtocol()+"</td>");
out.println(" </tr>");
out.println(" <tr>");
out.println(" <td bgcolor=pink>PathInfo:</td>");
out.println(" <td>"+request.getPathInfo()+"</td>");
out.println(" </tr>");
out.println(" <tr>");
out.println(" <td bgcolor=pink>Remote Address:</td>");
out.println(" <td>"+request.getRemoteAddr()+"</td>");
out.println(" </tr>");
out.println("</table>");
out.println("<hr>");
Date date = new Date();
out.println("<p align=center>Page generated on "+date);
out.println("</body>");
out.println("</html>");
out.close();

}

public void doPost( HttpServletRequest req, HttpServletResponse res)
throws IOException, ServletException{
doGet(req, res);
}
}
-------------------------------------------------------


June 3, 2008 at 6:54 PM


This is servlets mapping code.

<servlet>
<servlet-name>deploy</servlet-name>
<servlet-class>javacode.ServletDeploy</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>deploy</servlet-name>
<url-pattern>/jsp/ServletDeploy</url-pattern>
</servlet-mapping>


---------------------------------

Read for more information.

http://www.roseindia.net/servlets


Thanks

Amardeep









Related Tutorials/Questions & Answers:
servlets deploying - Java Beginners
servlets deploying  how to deploy the servlets using tomcat?can you please explain the total deploying and executing process?  Hi friend...); } } -------------------------------------------------------  This is servlets
DEVELOPING & DEPLOYING A PACKAGED EJB
' is very important in Enterprise Java. Compiling and Deploying such packaged servlets... and deploying Servlets with or without package and beans, along with JSP... DEVELOPING & DEPLOYING A PACKAGED EJB (WEBLOGIC-7) & ACCESSING
Advertisements
servlets
servlets  what is the duties of response object in servlets
servlets
servlets  why we are using servlets
servlets
what are advantages of servlets  what are advantages of servlets   Please visit the following link: Advantages Of Servlets
Servlets
Servlets  How to edit and delete a row from the existing table in servlets
servlets
servlets  How do you communicate between the servlets?   We can communicate between servlets by using RequestDespatcher interface and servlet chaining
servlets
what is the architecture of a servlets package  what is the architecture of a servlets package   The javax.servlet package provides interfaces and classes for writing servlets. The Servlet Interface The central
Servlets
Servlets  How to check,whether the user is logged in or not in servlets to disply the home page
servlets
servlets  why we require wrappers in servlets? what are its uses? Please explain   These wrappers classes help you to modify request...://www.roseindia.net/servlets/response-filte.shtml
Servlets
. Anyways, please visit the following links: http://www.roseindia.net/servlets/introductiontoconfigrationservlet.shtml http://www.roseindia.net/servlets
servlets
servlets  How to open and read the contents of a text file in servlets?   Please visit the following link: Read text file using Servlet
servlets
servlets   Hi what is pre initialized servlets, how can we achives?   When servlet container is loaded, all the servlets defined in the web.xml file does not initialized by default. But the container receives
Servlets and
Servlets and   Sir...! I want to insert or delete records form oracle based on the value of confirm box can you please give me the idea.... thanks
servlets
servlets why do we need web-inf directory in web application  why do we need web-inf directory in web application? means what's the benefits of doing so
servlets
which are the differ ways you can communicat between servlets  which are the differ ways you can communicat between servlets   Different ways of communicating between servlets:- 1)Using RequestDispatcher object. 2
servlets
package supports the development of servlets that use the HTTP protocol. The classes... javax.servlet.GenericServlet and serves as the base class for HTTP servlets. HttpServlet-Request
servlets
what are sessions in servlets  what are sessions in servlets   A Session refers to all the request that a single client makes to a server...: http://roseindia.net/jsp/jspsession/ http://www.roseindia.net/servlets
the servlets
what is diff between generic servlets and httpservlets  what is diff between generic servlets and httpservlets   Difference between GenericServlet and HTTPServlet: 1)GenericServlet belongs to javax.servlet package
servlets
regarding the user usage and habits. Servlets sends cookies to the browser client...://www.roseindia.net/jsp/jspcookies.shtml http://www.roseindia.net/servlets/use
servlets
servlets  hi i am using servlets i have a problem in doing an application. in my application i have html form, in which i have to insert on date value, this date value is retrieved as a request parameter in my servlet
servlets
what are filters in java servlets  what are filters in java   Filters are powerful tools in servlet environment. Filters add certain functionality to the servlets apart from processing request and response paradigm
servlets
servlets  what are different authentication options available in servlets   There are four ways of authentication:- HTTP basic authentication HTTP digest authentication HTTPS client authentication Form-based
Upload Code error on deploying
Upload Code error on deploying  on deploying the above code as it is said it is giving error that " No getter method for property thefile of bean org.apache.struts.taglib.html.BEAN " Error 500--Internal Server Error
Running and deploying Tomcat Server
Running and deploying Tomcat Server  HI Somebody has given the solution but it doesn't work out. kindly tell the solution for my problem which i described below I want to run a simple program on servlet and the application
Deploying Servlet in Weblogic 9.2 - Servlet Interview Questions
Deploying Servlet in Weblogic 9.2  Hi Friends, I am new to web application, can u explain briefly wat is "Deploying a .war,.jar,.ear files in target server. I am using Struts framework,servlets and hibernate.Jsp for page
Deploying website war file on linux
Deploying website war file on linux  I have BOLLYWOOD_MIRROR.war file.I want to host it on linux server on path. After deployment of war file its reflecting 404 error while it is proper working locally. I need step by step
Deploying and testing Stateless Session Bean
Deploying and testing Stateless Session Bean       ...; </project> Deploying
Deploying Servlet in Weblogic 9.2 - Servlet Interview Questions
Deploying Servlet in Weblogic 9.2   Hi Friend thanks in advance, can u give me steps for deploying servlet using weblogic server 9.2
Deploying Weblogic Server in MyEclipseBlue6.6 - IDE Questions
Deploying Weblogic Server in MyEclipseBlue6.6  Hi I am facing some problem in deploying "weblogicserver8.1" in my "MyEclipseBlue6.6".Please provide me detailed path of BEA home directory, Web logic Installation directory
Wats Deploying war in Target Server - Development process
Wats Deploying war in Target Server   Hi Friends, I am new to web application, can u explain briefly wat is "Deploying a .war,.jar,.ear files in target server. Thank u in advance   Hi rajendra
Tutorials   
Java Spring Hibernate Struts Training Retrieve database from the table dynamically in jsp from oracle using servlet What does core Java include? java What are some way to learn Java quickly? Is it required to learn Java before learning Java Script? Is it necessary to learn java script before learning PHP? Are HTML5 and Java Script boosts Java career? Is Java object oriented? Fingerprint application with Java Uninstall Oracle Virtual Box JSON to HashMap Free Java online Training I want example of Control Statement in Java ANSI Color Codes with Python Create a Program that Calculates Input What is difference between JDK,JRE and JVM? How to see ubuntu version on server? How to get Page Source in Selenium (WebDriver) using Java? The path to the driver executable must be set by the webdriver.gecko.driver system property parse data from a link in java Java Program Qns using BlueJ How to fix HAX Kernel Module Is Not Installed error? Installing Audacity Looking for code Logic to check track changes & Coments in MSWord, MSWordx, MSExcel, MSExcelx is ON/OFF Installing JDK on Mac SAX Parser exception ERROR 601 (42P00): Syntax error. Encountered Thread java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory How to install Ubuntu 16.04 LTS? HttpServletRequest cannot be resolved to a type in eclipse - Solved Unhandled event loop exception GC overhead limit exceeded Spring Data jpa with apache phoenix Caused by: java.lang.IllegalArgumentException: Not a host:port pair: PBUF o.a.h.h.z.RecoverableZooKeeper - Possibly transient ZooKeeper, quorum= com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager class not found com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager not found How to download and install Java 8 on Windows? How to uninstall JDK 7? How to install gtk-doc-tools package in Ubuntu? How to install Oracle JDK 8 on Ubuntu? ejabberd_ctl.beam not found - Solved How to convert date to UTC format in Java? How to install autoconf, automake and libtool in Ubuntu 15.10? How to convert current date to mm dd yyyy format in Java? How to convert current date to dd mm yyyy format in Java? How to stop window closing in "internalFrameClosing" event. How to find list of all index in Neo4j? neo4j-server.properties file location SASLError using PLAIN: not-authorized

Ads

 
Advertisement null

Ads