servlets

How to detect Tomcat Startup Programmatically from within a Servlet?

喜你入骨 提交于 2021-01-29 05:40:21
问题 Question How can you programmatically determine when Tomcat has completed startup? I mean programmatically from within a WAR file running on Tomcat, most likely via a Servlet that can tap into container info if possible? Background The Catalina log entry that you normally see after a WAR has fully deployed would be equal to what I'm looking for. I have a constraint that makes parsing the logs undesirable. But the data that goes to Catalina.out is precisely what I'm looking for. I'm trying to

session().getAttribute is returning null

时光总嘲笑我的痴心妄想 提交于 2021-01-29 04:35:51
问题 I have a servlet which calls a jsp page. In the servlet I am retrieving the username provided at the login correctly. But after setting the same in session, when i access the called jsp page, its returning null. Servlet Code: public class AdminServlet extends HttpServlet { /** * */ private static final long serialVersionUID = -4244742541587179390L; public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String userName = request

how does jsp:useBean scope attribute work?

放肆的年华 提交于 2021-01-29 03:28:46
问题 I am trying to understand how exactly scope attribute in jsp:useBean JSP action tag works. In my understanding scope is used to indicate where the bean is located (request,session,application etc.), but after some testing I came across an interesting situation where it's not the case, please consider the following JSP code (I am using scriplets here just for the sake of simplicity): <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" import=

how does jsp:useBean scope attribute work?

℡╲_俬逩灬. 提交于 2021-01-29 03:25:23
问题 I am trying to understand how exactly scope attribute in jsp:useBean JSP action tag works. In my understanding scope is used to indicate where the bean is located (request,session,application etc.), but after some testing I came across an interesting situation where it's not the case, please consider the following JSP code (I am using scriplets here just for the sake of simplicity): <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" import=

How to pass new header to sendRedirect

不打扰是莪最后的温柔 提交于 2021-01-28 19:12:25
问题 I feel like this should be easy. I have an app where all I am trying to do is have a form page (index.jsp) that calls a servlet (CheckInfo.java) which sets a new header (myHeader) and redirects the user to another page (redirect.jsp). All of these files are on the same server. The index.jsp is sending the request just fine and CheckInfo is processing and redirecting, but myHeader is not showing up on redirect.jsp. I've read several posts talking about response.sendRedirect sends a 302 which

Can't access CSS and JavaScript files in JSP

≯℡__Kan透↙ 提交于 2021-01-28 19:07:56
问题 I am developing a application in JSP/Servlet using MVC. In this application I want to load index.jsp as welcome page and this page retrieves the data from database. I did it. Now the problem is that when index.jsp page loads it fetches data from database but it shows it on browser as plain text and my CSS is not working for it. I know that during translation phase JSP is converted into servlet and after processing it send output to browser so during that we have to write the relative path of

Tomcat v9.0 Server at localhost failed to start in Eclipse

折月煮酒 提交于 2021-01-28 13:04:12
问题 I have a problem with Tomcat, it stopped working. I installed Tomcat 3 weeks ago and I have made more than 50 web dynamic projects, maven projects and everythings worked great. And today Tomcat stopped working. For example I make a project in Eclipse and when I try to run it I get this error: Server Tomcat v9.0 Server at localhost failed to start. I can start Tomcat from Windows services, and I can open http://localhost:8080/ page in browser, but I can't start Tomcat in eclipse. Not just for

Tomcat v9.0 Server at localhost failed to start in Eclipse

♀尐吖头ヾ 提交于 2021-01-28 13:03:54
问题 I have a problem with Tomcat, it stopped working. I installed Tomcat 3 weeks ago and I have made more than 50 web dynamic projects, maven projects and everythings worked great. And today Tomcat stopped working. For example I make a project in Eclipse and when I try to run it I get this error: Server Tomcat v9.0 Server at localhost failed to start. I can start Tomcat from Windows services, and I can open http://localhost:8080/ page in browser, but I can't start Tomcat in eclipse. Not just for

Jersey error when trying to suspend a connection of an asynchronous request

こ雲淡風輕ζ 提交于 2021-01-28 11:58:00
问题 Im doing a small test on suspending a asynch request using jersey but im getting an error. Let me show you what im trying to do and by the way the server is up and running just this request is failing: Path("/json/metallica") public class JSONService { @GET @Path("/test") @Produces(MediaType.APPLICATION_JSON) public void getAsynchHealthyTracks(@Suspended AsyncResponse asyncResponse){ HealthService.getInstance().getHealththyTracks(asyncResponse); } } when i call this from my local host on

what happens when I configure a servlet before a filter in tomcat's web.xml?

有些话、适合烂在心里 提交于 2021-01-28 11:57:18
问题 In tomcat for a certain url, I want to skip all the filters and execute a servlet and I thought placing the servlet before the filter will to as I expected but still the filters behind the servlet mappings are executing. Am I doing anything wrong? For instance, this is my web.xml <servlet> <servlet-name>APIRedirection</servlet-name> <servlet-class>com.test.APIRedirection</servlet-class> </servlet> <servlet-mapping> <servlet-name>APIRedirection</servlet-name> <url-pattern>/abc/*</url-pattern>