37459

Java Web Application specify entry point

Question:

I have some Java Web Application and now it's starting from index.jsp page. I have my own class with following code:

import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class EntryPointClass extends HttpServlet { @Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { .... } }

My MANIFEST.MF file looks like:

Manifest-Version: 1.0 Main-class: asap.vito.mobileapi.EntryPointClass

But anyway, after deleting index.jsp I have a 404 error.

What should I change to start my app directly from my java class?

Thank you.

Answer1:

First of all its a servlet not simple java class... You should give its mapping into the web.xml and then u can access it directly

give this type of mapping for your servlet

<welcome-file-list> <welcome-file>entryPointClass </welcome-file> </welcome-file-list> <servlet> <servlet-name>EntryPointClass </servlet-name>//servlet name here <servlet-class>examples.EntryPointClass </servlet-class> // packagename.servletclassname </servlet> <servlet-mapping> <servlet-name>EntryPointClass </servlet-name>// servletname <url-pattern>/entryPointClass </url-pattern> // url parttern by which you will access your servlet </servlet-mapping>

To access this from server use projectname/urlpattern

Answer2:

Change/Add Welcome File Tag Element in Web.xml Configuration or Use Servlet Mapping.

Recommend

  • The API package 'channel' or call 'CreateChannel()' was not found
  • File Upload handler
  • ExtJS 4 Spring 3 file upload. Server sends bad response content type
  • How to silently drop a request in Tomcat?
  • How can I configure HTTP Response Headers in a Struts2 Interceptor?
  • problem with classes not found during PlayPlugin.enhance
  • Runtime error in UVA Online Judge [closed]
  • Is it mandatory to have a doGet or doPost method?
  • 3.0.0.M1: SSL - Invalid keystore format
  • Authentication failed with Azure Active Directory in Windows Phone
  • How to copy styled text in JTextPane
  • How to get listview position?
  • Regarding starting the threads on a condition
  • Center align outputs in ipython notebook
  • Android Activity.onWindowFocusChanged doesn't get called from within TabHost
  • Zoom in and out of jPanel
  • Creating Java object from class name with constructor, which contains parameters [duplicate]
  • GridView breaks while scrolling
  • How to use RequestBodyAdvice
  • How to test if a URL from an Eclipse bundle is a directory?
  • NHibernate Validation Localization with S#arp Architecture
  • how to do an event when i swipe from fragment to the other
  • Update CALayer sublayers immediately
  • JFileChooser in front of fullscreen Swing application
  • Array.prototype.includes - not transformed with babel
  • How would I use PHP exceptions to define a redirect?
  • How to add date and time under each post in guestbook in google app engine
  • How to redirect a user to a different server and include HTTP basic authentication credentials?
  • Symfony2: How to get request parameter
  • Is there a mandatory requirement to switch app.yaml?
  • File upload with ng-file-upload throwing error
  • ExecuteAsync RestSharp to allow backgroundWorker CancellationPending c#
  • AngularJs get employee from factory
  • log4net write single file for each call to log.info
  • Getting error when using KSoap library to consume .NET web services
  • unknown Exception android
  • EntityFramework adding new object to nested object collection
  • Checking variable from a different class in C#
  • failed to connect to specific WiFi in android programmatically
  • How can I use threading to 'tick' a timer to be accessed by other threads?