solved: helloword tomcat w3schools
Hi guys- I solved the castiing problem with jakarta. The jakarta is used instead of javax now. I needed to update my pom and then run mvn install -U. The servlet runs correctly on tomcat now. thanks all, jim Sent with Proton Mail secure email. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
additional pom to go with w3schools helloworld question (formatted)
Hi - Here is my formatted pom. thanks http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd; xmlns="http://maven.apache.org/POM/4.0.0; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance;> 4.0.0 local NewJavaMavenProject NewJavaMavenProject 0.1.0-SNAPSHOT war 3.8.1 17 17 javax.servlet javax.servlet-api 4.0.0 provided exclude-central-repo true central https://repo.maven.apache.org/maven2 true true src/main/java maven-compiler-plugin true org.apache.maven.plugins maven-war-plugin 3.4.0 org.apache.maven.plugins maven-jar-plugin Sent with Proton Mail secure email. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
plaint text version of question: hello world w3schools (tomcat)
Hi- I am resending my msg. in plain text wondering how to get tomcat to render my servlet for hellworld from code I got at w3schools. I am trying to follow the guidelines: TOMCAT 10.1.10 + plain text email! THANKS code and configuration files: import java.io.IOException; import java.io.PrintWriter; import javax.servlet.Servlet; import javax.servlet.ServletConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; /** * This servlet program is used to print "Hello World" on * client browser by implementing servlet interface. * @author w3spoint */ public class HelloWorld implements Servlet { private static final long serialVersionUID = 1L; //no-argument constructor. public HelloWorld() { } ServletConfig config=null; @Override public void init(ServletConfig config) throws ServletException { this.config = config; System.out.println("Do initialization here."); } @Override public void destroy() { System.out.println("Do clean-up process here."); } @Override public ServletConfig getServletConfig() { return config; } @Override public String getServletInfo() { return "w3spoint.com"; } @Override public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println("Hello World example using " + "servlet interface."); out.close(); } } http://java.sun.com/xml/ns/j2ee; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance; xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd;> HelloWorld HelloWorld HelloWorld /HelloWorld url: http://localhost:8080/examples/HelloWorld error msg: Root Cause java.lang.ClassCastException: class HelloWorld cannot be cast to class jakarta.servlet.Servlet Sent with Proton Mail secure email. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
new user trying to get a sample servlet to run from w3school
Hi- I get the following error msg on tomcat at this URL: http://localhost:8080/examples/HelloWorld I am wondering it seems like I am getting the maven project to build in Moonshine IDE. then I put a new web.xml file in the examples directory in the tomcat server unzipped files. Then, I try to copy my class over and run the example, and I get this error msg. listed below. I just want to try to deploy one or two servlets which I know little about, so I can switch to blazeds and use tomcat. It's kind of like a helloworld to tomcat intro. I am hoping to use apache royale with blazeds. Any help is greatly appreciated. THANKS. j. mcnamara Root Cause java.lang.ClassCastException: class HelloWorld cannot be cast to class jakarta.servlet.Servlet import java.io.IOException; import java.io.PrintWriter; import javax.servlet.Servlet; import javax.servlet.ServletConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; /** * This servlet program is used to print "Hello World" on * client browser by implementing servlet interface. * @author w3spoint */ public class HelloWorld implements Servlet { private static final long serialVersionUID = 1L; //no-argument constructor. public HelloWorld() { } ServletConfig config=null; @Override public void init(ServletConfig config) throws ServletException { this.config = config; System.out.println("Do initialization here."); } @Override public void destroy() { System.out.println("Do clean-up process here."); } @Override public ServletConfig getServletConfig() { return config; } @Override public String getServletInfo() { return "w3spoint.com"; } @Override public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println("Hello World example using " + "servlet interface."); out.close(); }} // the sample code taken from w3schools builds right the web.xml reads from conf/server.xml my pom.xml looks like this: http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd; xmlns="http://maven.apache.org/POM/4.0.0; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance;> 4.0.0 local NewJavaMavenProject NewJavaMavenProject 0.1.0-SNAPSHOT war 3.8.1 17 17 javax.servlet javax.servlet-api 4.0.0 provided exclude-central-repo true central https://repo.maven.apache.org/maven2 true true src/main/java maven-compiler-plugin true org.apache.maven.plugins maven-war-plugin 3.4.0 org.apache.maven.plugins maven-jar-plugin Sent with [Proton Mail](https://proton.me/) secure email.