I deployed war file with some static resource (.zip) on glassfish server # physical location {WebAppRoot}/resources/WebFiles/zippedFiles/{FileName}.zip so for downloading/accessing file from browser relative path or URI will be {domain.com}/resources/WebFiles/zippedFiles/{FileName}.zip.Someday before i am trying to enable resume support for downloading such files after some Googleing i come to know that i have to tell glassfish that .zip file is an static content,so after adding
<servlet-mapping>
<servlet-name>DefaultServlet</servlet-name>
<url-pattern>.zip</url-pattern>
</servlet-mapping>
Resume support is enabled.
So my question is,Before adding <servlet-mapping> how the .zip file is served? Is that file handled by DispatcherServlet (Dynamic content)? How the server knows URI({domain.com}/resources/WebFiles/zippedFiles/{FileName}.zip) is of an file not the controller or JSP (view) for which DispatcherServlet is resposible.
And one last what is benefit of adding such <servlet-mapping>?
There is a 'default servlet' that handles all unmapped resources.
Related
I have an existing jetty application that i need to modify. Basically i just need one access point that can handle POST requests. I have access to the WEB-INF directory of the project. There i have web.xml file and a lib folder. As i understand from jetty documentation jars under lib will be loaded automatically. Is it possible to add a custom jar under lib folder and the somehow configure web.xml so that my jar will handle HTTP requests from a certain URL? If so how would i start with that?
You can simply create a jar with your Servlet class inside (a class that extends HttpServlet) and add the servlet declaration inside the web.xml
<servlet>
<servlet-name>A_Name</servlet-name>
<servlet-class>your.new.ServletClass</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>A_Name</servlet-name>
<url-pattern>/the/path/you/want</url-pattern>
</servlet-mapping>
I have an mp4 video on my GlassFish java application server. What URL do I use to access it in a browser?
The video path in the application on the server is:
myapp/WEB-INF/videos/myvideo.mp4
I tried adding this to my web.xml file:
<servlet>
<servlet-name>myvideo</servlet-name>
<servlet-class>videos.myvideo.mp4</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>myvideo</servlet-name>
<url-pattern>/myvideo</url-pattern>
</servlet-mapping>
and restart the server, then go to the URL: https://www.example.com/myapp/myvideo but that just gave this error:
java.lang.ClassNotFoundException: videos.myvideo.mp4
Obviously it's not a servlet, but not sure what else to try.
Why are you trying to access the video as a servlet and not as a static asset, like you would an image? Using a servlet mapping is obviously wrong.
Instead if you have a running WebApp in GlassFish you should be able to access it via https://www.example.com/myapp/videos/myvideo.mp4 assuming you've put the videos folder under your webapp's j2ee root.
The j2ee root would be configured in your application.xml as the web-uri. In your case it is likely that the myapp folder is your j2ee root. So move your videos up a folder.
(Converted comment 'discussion' into an answer).
So I have this google app engine app that a development company developed and they put a test server up online and it works completely. I can build the app locally and run it on the gae dev server locally and everything works, but when I upload to google app engine it gets errors and 404 page not found. I fixed all the errors by including specific .jar files in the WEB-INF/lib directory that I found in target/lib.
I've tried just including all the .jar files that are in the target/lib directory but then the app gets errors locally so I've had to find the specific files and include those in the WEB-INF/lib directory.
In the logs I get this error
org.springframework.web.servlet.PageNotFound noHandlerFound: No mapping found
for HTTP request with URI [/api/universe/v1/auth/signup/student/email] in DispatcherServlet
with name 'spring-dispatcher'
For this error I can't find which file may be missing that I need to include in the WEB-INF/lib directory because I have already included all of the spring .jar files. What file may I be missing? Is there anything else I should include in here to help find what the problem is?
Also if there a way to see what files are being uploaded to google app engine? If I could just see what was missing I could stick it into the WEB-INF/lib directory.
Your error message indicates that there's a servlet-mapping element missing and/or improperly set up for the DispatcherServlet ('spring-dispatcher' could either be a param-name or the actual servlet-name, without your web.xml file I cannot say for certain). You can set the servlet-mapping element in the web.xml file in WEB-INF.
As an example, a given servlet could be set up like this:
<servlet>
<servlet-name>redteam</servlet-name>
<servlet-class>mysite.server.TeamServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>redteam</servlet-name>
<url-pattern>/red/*</url-pattern>
</servlet-mapping>
There's documentation here for more information on the web.xml file
I m trying to debug some jsp pages in eclipse. These pages depends on some other projects, that are located in workspace. The physical files are located in webapps directory. I'm using tomcat7 as server. I have started Tomcat with standard configuration(debug at port 8000) and left also port 8000 in remote debug configuration. In my workspace there is a ic-config with WEB-INF and web.xml. It maps com.quartal.irtoolbox.ic.ControllerServlet to Controller like the following:
<servlet>
<servlet-name>Controller</servlet-name>
<servlet-class>com.quartal.irtoolbox.ic.ControllerServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Controller</servlet-name>
<url-pattern>/Controller</url-pattern>
</servlet-mapping>
But when i try to access Controller , it is not accessible at all.I'm getting the error: "The requested resource (/Controller) is not available". What should i change and how should i call the servlet to be able to get and debug it?
Thanks
Magda
GWT RPC call don't seems to work when i deploy my war file to TOMCAT (tomcat/webapps/ROOT/war).
It gives me an error:
The requested resource
(/war/myproject/call) is not
available.
If i change the directory structure and then deploy directly war contents (not war directory itself), like (tomcat/webapps/ROOT/project.html, project.css, project, etc...) then it works.
Can someone please explain me whats going on?
I think there might a problem at:
<servlet>
<servlet-name>callServlet</servlet-name>
<servlet-class>com.myproject.server.dao.Call</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>callServlet</servlet-name>
<url-pattern>/myproject/call</url-pattern>
</servlet-mapping>
The thing is that a single Tomcat server can have multiple applications deployed, each in its so-called context. The applications are deployed in the webapps folder and each folder is mapped to one context, while the ROOT folder is the default (no-context).
To access an application on Tomcat, you specify the context after the URL. For example if you had an application (context) Test in webapps/Test folder, you would access it like this:
http://localhost:8080/Test
But applications in the ROOT folder have no context and are accessed by simply going to localhost:8080. And this is your case. Tomcat is looking for you application directly in the ROOT folder but you have your app in the ROOT/war folder. In other words, the RPC call expects the myproject folder to be under the ROOT folder and not under the ROOT/war folder. That's why it's not working.
If you still wanted to have your war folder within the ROOT folder, you would have to change the url-pattern to /war/myProject/call.
Well i found the solution, it had to do with Tomcat's way of operation.
Open your project war directory
Select all the files (html/jsp , images, WEB-INF etc...)
Compress all the files into a single project.zip archieve
Rename the project.zip into project.war
Copy project.war into Tomcat/webapps/
Restart Tomcat server
You will now notice inside webapps directory that project.war has been decompressed into a project directory, if you open it you will find all the .war contents(html/jsp, images, WEB-INF, etc...)
Access it from here http://localhost/project or http://localhost/project/index.html or index.jsp.
The error was: I was compressing only the war directory (not it's inside contents) into project.war.
look like, servlet is not initializing for you war try to change SERVLET tag as
i.e. add tag
<load-on-startup>1</load-on-startup>
this tag ensures that servlet should be loaded
<servlet>
<servlet-name>callServlet</servlet-name>
<servlet-class>com.myproject.server.dao.Call</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
hopefully this will work