330xi
330xi

Reputation: 97

How to make servlets for openshift tomcat?

So I got all keys, tools for Eclipse, created new deafult applicaion, ok it shows somepage.

Then I change

src/main/webapp/WEB-INF/web.xml

as it is told to in readme on:

    <servlet>
    <servlet-name>work</servlet-name>
    <servlet-class>kea.webpro.WorkServlet</servlet-class>    
  </servlet>  
  <servlet-mapping>
    <servlet-name>work</servlet-name>
    <url-pattern>/work</url-pattern>
  </servlet-mapping> 

And add some java-classes in

src/main/java

And then I go here i get

java.lang.ClassNotFoundException: kea.webpro.WorkServlet at first time and next times resource not found.

I guess my custom web.xml has been succesfully read. But my java class unfortunately not. So how to make simple servlet that generating some simple html-page with hello world on openshift tomcat?

At my local tomcat everything is fine, I generate whatever i want to. though my servlet structure is much more simple.

Upvotes: 4

Views: 2885

Answers (1)

user2879327
user2879327

Reputation:

You need to add the javax.servlet-api to your pom.xml file. Check out this tutorial and it will help you out about what to add to your pom.xml and where. Also, you can use Servlet 3.0 and use annotations instead of the old web.xml way.

https://www.openshift.com/forums/openshift/how-to-upload-and-serve-files-using-java-servlets-on-openshift

Upvotes: 6

Related Questions