How to register servlets in WSO2 Carbon based products

I wanted to register servlets with WSO2 Greg(Governance Registry), but couldn’t do it with normal way. That is, registering the servlets in web.xml. In wso2 based products we can write our own OSGi bundles where for each feature we have to write a Front End(FE) and a Back End(BE) bundle. Basically the FE bundle will be for the user interface and the BE bundle will serve the requests from FE.
We can register our servlets via the FE bundle. In FE bundle you have to create a file “components.xml” under META-INF directory. In this file you can register you servlets as described below,

<component xmlns="http://products.wso2.org/carbon">
    <servlets>
	<servlet id="HelloWorld">
	    <servlet-name>helloworldservlet</servlet-name>
	    <url-pattern>/foo/helloWorld</url-pattern>
	    <display-name>Hello World</display-name>
	    <servlet-class>"your servlet class"</servlet-class>
	</servlet>
    </servlets>
</component>
Advertisements

About kishanthan

I’m currently working as a Software Engineer at WSO2, an open source software company. I hold an Engineering degree, majoring in Computer Science & Engineering field, from University of Moratuwa, Sri Lanka.
This entry was posted in How to, WSO2 and tagged , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s