Google App Engine /del url error - java

I'm getting an error when I try to delete via link /del. It gives me this error, as shown bellow:
Error: Not Found
The requested URL /del?eid=5769015641243648 was not found on this server.
I think it has something to do with my servlet mapping or what?
<servlet>
<servlet-name>CreateNewEvent</servlet-name>
<servlet-class>com.Norbu.EventsPortal.ServletCreateEvent</servlet-class>
</servlet>
<servlet>
<servlet-name>DeleteEvent</servlet-name>
<servlet-class>com.Norbu.EventsPortal.ServletDeleteEvent</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>CreateNewEvent</servlet-name>
<url-pattern>/add</url-pattern>
</servlet-mapping>
<sevlet-mapping>
<servlet-name>DeleteEvent</servlet-name>
<url-pattern>/del/*</url-pattern>
</sevlet-mapping>
<welcome-file-list>
<welcome-file>EventsPortal.jsp</welcome-file>
</welcome-file-list>
This is the delete link code that I'm using:
<a href="/del?eid=<%=eventid%>">
This is the warning message in the log file
No handlers matched this URL.
Is there anyone that could help me solving the issue I'm having?

Check spelling. You have sevlet-mapping

Related

index.html [welcome file] gives HTTP Status 404 – Not Found

please see my project structure here.I am using Spring MVC here is my code.
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
when I hit run the project on server I got below error .
HTTP Status 404 – Not Found
as per the concept if we do not specify the welcome list tag then automatically index.html file will be searched.but in my case it is not working however it is working if I change the extension to .jsp.
If any one knows the answer please help me .
Note: I dont want to change the url mapping. I know there are alternatives but I want to know why this is happening and not showing me the result

Serving single page app next to other war file in Tomcat

I have a Tomcat server, serving two .war files. The first one is mapped to context /api, the second one to root /. The latter contains a single-page AngularJS app. It has the following web.xml config:
<servlet>
<servlet-name>webapp</servlet-name>
<servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>listings</param-name>
<param-value>false</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>webapp</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<error-page>
<error-code>404</error-code>
<location>/</location>
</error-page>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
When I go to https://my.url/, the index page of the single page app is properly served. So far, so good.
The problem is, when I deeplink to a page in my single page app, for example https://my.url/some/resource, Tomcat will give a 404. Because of the error-page config, it will still return the index page, but still with status 404. So, it kind of works, but not nicely.
Can I get Tomcat to return the index page with a proper 200 status code for all deep links? Of course, calls to /api should still resolve to the other deployed .war. I want to avoid duplicating the AngularJS url definitions in Tomcat, so it should just return the index page for any request that doesn't start with /api/.
For deeplinks you need to use wildcards on your webapp url pattern. Something like:
<url-pattern>/*</url-pattern>
Not sure would it not catch the /api/ calls then. Some more advanced url pattern might be required.

java servlet url mapping doesn't work

In the java servlet, how to do mapping with this url :
http://localhost8080/myproject/client/1234
the 'myproject' is my root context.
I have tried the /**/client/* , it doesn't work.
Please advise.
You are doing it wrong
First of all URL should be
http://localhost:8080/myproject/client/1234
then for doing mapping do it like
<servlet-mapping>
<servlet-name>app</servlet-name>
<url-pattern>/client/* </url-pattern>
</servlet-mapping>

Hide .jsp extension in JSP project using servlet mapping

I am writing an application in JSP, and I need to remove the ".jsp" extension from the URL. For example, I need:
http://example.com/search.jsp?q=stackoverflow
To be:
http://example.com/search?q=stackoverflow
I know that this can be done using the ".htaccess" file, but I need some other way. I have tried the following code:
<servlet-mapping>
<servlet-name>jsp</servlet-name>
<url-pattern>*.</url-pattern>
</servlet-mapping>
However, this did not work. Does anyone have some suggestions for ways to accomplish this? Thanks in advance for any help.
With a servlet mapping you need to specify each JSP individually like follows:
<servlet>
<servlet-name>search</servlet-name>
<jsp-file>/search.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>search</servlet-name>
<url-pattern>/search</url-pattern>
</servlet-mapping>
It's easier if all those JSPs are in a common path. E.g. /app/*.
<servlet>
<servlet-name>app</servlet-name>
<servlet-class>com.example.FriendlyURLServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>app</servlet-name>
<url-pattern>/app/*</url-pattern>
</servlet-mapping>
with
request.getRequestDispatcher("/WEB-INF" + request.getPathInfo() + ".jsp").forward(request, response);
This assumes the JSPs to be in /WEB-INF folder so that they cannot be requested directly. This will show /WEB-INF/search.jsp on http://example.com/app/search.
Alternatively, you can use Tuckey's URLRewriteFilter. It's much similar to Apache HTTPD's mod_rewrite.

web.xml servlet mapping infinite loop

I am using appengine and seem to be having some problems with url routing
My web.xml
<servlet>
<servlet-name>ViewServlet</servlet-name>
<jsp-file>viewdata.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>ViewServlet</servlet-name>
<url-pattern>/view/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>default.html</welcome-file>
</welcome-file-list>
The redirection works just fine when I test in the local machine. On upload to appengine when I try to navigate to http://myurl/view/ it redirects infinitely to
http://myurl/view/default.html/default.html...
Is this the right way to redirect in web.xml. Am I missing something here. It work fine on the local machine. Just goes into an infinite loop when uploaded onto gae. Any help would be appreciated...
Note that the <jsp-file> must start with a forward slash (/) if the JSP is in the application's root directory.

Categories