Hi,
Does any one have an idea about adding servlets using addServlet method in gateway?
Some pointers to examples will be appreciated.
Regards
PRAMANJ
Hi,
Even if you add a servlet ingateway context usign addServelet method, I don’t see any server names in the server tab in Eclipse ! Where do I see the web.xml to see existing servlets in the gateway context and to add the new servlet for my module that I want to add?
SAny help will be appreciated.
Regards
PRAMANJ
Let me tell you what I did.
i add the following lines in main/WEB-INF/web.xml file.
HelloServlet
com.pramanj.test.gateway.HelloServlet
HelloServlet
/HelloServlet
where servlet file HelloServlet.java (which just prints “Hello World”) is added to the same package where my-module.java is added. The module builds successfully, but when I enter localhost:8088/HelloServlet , I get a page displaying the standard ignition main page, not the expected new page with HelloWorld! It it getting redirected to main page on whatever value to enter in the page?How to supress the redirection for HelloServlet page?
PRAMAN
This should work:
No actually localhost:8088/main/HelloServlet also gives following error.!
HTTP Status 404 - /main/HelloServlet
type Status report
message /main/HelloServlet
description The requested resource is not available.
Apache Tomcat/6.0.36
===========
Should i change the url-mapping to /main/HelloServlet ?
regards
PRAMANJ
I’m using the following pattern:
<url-pattern>/HelloServlet/*</url-pattern>
I’m also using a Filter, but that shouldn’t matter. You should try compiling your java file and packaging it up into a jar file that goes in the main/WEB-INF/lib folder.
Also, don’t forget to restart the gateway every time you make a change to the web.xml (or the jar file).
Hello,
I have a servlet working successfully in Ignition.
I didn’t do anything with web.xml or main/WEB-INF/lib folder.
I simply called context.addServlet and then I was able to access the servlet from: localhost:8088/main/system/MyServlet
For example, in my GatewayHook.java:
@Override
public void setup(GatewayContext context) {
context.addServlet("MyServlet", MyServlet.class);
}
Nick
Thanks a lot every one for the response. I will try it and see if it works. Looks like Ignition does a lot of intelligent things hiding the lower level details from developers. It will be nice if Kevin can comment on how exactly the addServlet method in Ignition works?
regards
PRAMANJ
yes it seems to work. unfortunately its not properly documented.
best regards
PRAMANJ
Now having solved the calling servlet problem (mysteriously!) , next question is how to add an HTML page in the main:8088 web application? As per the \tomcat\webapps\ROOT\WEB-INF\web.xml file every thing gets redirected to DefaultContextRedirector servlet.
Any thoughts will be appreciated.
Regards
PRAMANJ
You should try putting your HTML files in the same directory as the WEB-INF and then calling the request dispatcher from your servlet:
request.getRequestDispatcher("/WEB-INF/" + request.getPathInfo() + ".html").forward(request, response);
Thanks for the tip, i will think it over and try. But my worry is if Ignition itself puts a filter on the http requests and redirects all http to its main page then my servlet will not be called atall! Or may be i should first invoke my servlet manually which will redirtect to other THML pages of maine.
Am i missing something here?
Best regards
PRAMANJ
A post was split to a new topic: Adding Servlets Redux