servlets

Properties file as init-param in web.xml

纵饮孤独 提交于 2019-12-24 14:05:55
问题 I am migrating a Jsp-servlet based Java project that was hosted in websphere to tomcat. Following init-param is in web.xml inside a filter definition. I moved the properties file src folder which is classpath. How to change the following in the web.xml. Can I define properties file as init-param because most of the answers I saw has used context-param to define properties file. I dont think its an option to me as the existing application needs the properties file to be init-param. <init-param

@EJB inside utility class is null

浪尽此生 提交于 2019-12-24 14:02:23
问题 I have a form in my application for which I'm trying to validate that the userName and/or email is not already on the DB. This is service class: @Stateless public class CustomerFacade extends AbstractFacade<Customer> { @PersistenceContext(unitName = "OnlineStorePU") private EntityManager em; @Override protected EntityManager getEntityManager() { return em; } public CustomerFacade() { super(Customer.class); } } This is the entity class: @Entity @Table(name = "customer") @XmlRootElement

org.hibernate.AnnotationException: No identifier specified for entity: login.Users

Deadly 提交于 2019-12-24 13:57:15
问题 I am getting an error while reuest goes to servlet ,I try alot for resolved this but not get proper solution. Registration.java (Servlet class file) package login; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate

How to Handle JsonSyntaxException when Receiving Response from GAE

徘徊边缘 提交于 2019-12-24 13:54:56
问题 I am trying to replicate the Google App Engine Servlets module here using Retrofit instead of AsyncTask. I find it odd, but apparently Retrofit 2.0 does not support connections to Google App Engine, as stated here in the issues of the GitHub repository. As a result, I am using Retrofit 1.9 and OkHttp 2.3 dependencies. I have created a project called "Retrofit Test" in the Google Developer Console, and Google has supplied me with a URL for the project: "http://retrofit-test-1203.appspot.com"

Struts 1.1 and Servlet 2.5 - NoClassDefFoundError for JspException during tests

落爺英雄遲暮 提交于 2019-12-24 13:44:08
问题 After updating servlet-api provided dependency in pom from 2.3 to 2.5, unit tests for our custom Struts 1.1 RequestProcessor started to fail with NoClassDefFoundError: javax/servlet/jsp/JspException, which indeed is lacking in servlet-api-2.5, compared to 2.3. I use JUnit 4.11 and JMockit 1.2 for unit testing. Interestingly, the application works fine after deploying it to JBoss 5.1. Is Struts 1.1 compatible with web apps using servlet api 2.5? Maybe JBoss 5.1 servlet-api is different from

Show error msg if record is failed to be deleted in jsp

倾然丶 夕夏残阳落幕 提交于 2019-12-24 13:39:15
问题 I am developing web based application where I needs to delete parent entries if user thinks it will no need to maintain. If parent entry doesn't have any record in child table then entry will get deleted but if it has records in child table then I wants to show error message with entry exists in which table. I am following MVC architecture using jsp and servlet. 回答1: Notice the following, if your tables are well defined I mean, the child records must reference the parent records (read about

Sending audio file from android to servlet

走远了吗. 提交于 2019-12-24 13:23:50
问题 How to send an audio file from android phone to servlet. i have surfed so many sites but not getting the proper solution. Can anyone please help me.How many ways are there for sending an audio file from android to server. 回答1: HttpRequestWithEntity.java import java.net.URI; import java.net.URISyntaxException; import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; public class HttpRequestWithEntity extends HttpEntityEnclosingRequestBase { private String method; public

load on startup and Jersey

梦想的初衷 提交于 2019-12-24 13:18:50
问题 Possibly duplicate of Servlet not loading on startup, however Im not allowed yet to comment, so I have to start a new question for this... Same setting, having a servlet using Jersey and Tomcat, using load-on-startup for loading the container. However, due to the thread mentioned above, I understand that this only load the Jersey container but not the classes I setup for the servlet. So, related to what is implied in the answer of the thread above, how is it done that not only the contained

Java New Session For Each Request?

谁都会走 提交于 2019-12-24 13:13:31
问题 I have been having an issue with session variables not being available when a request has come from a domain name as opposed to localhost. For instance, if I set a user variable: request.getSession(true).setAttribute("user", user); //Redirects to another html page or something... When the client makes another request and I attempt to access the user session variable it returns null. //Client makes another request to the server request.getSession(true).getAttribute("user"); //returns null I've

doGet or doPost method invocation [duplicate]

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-24 12:52:58
问题 This question already has answers here : How doGet() or doPost method invokes service() method internally (3 answers) Closed 3 years ago . How does the servlet container know whether to call doGet or doPost method. When I make a get request doGet is called, When I make a post request doPost is called , but where is the logic to decide this . 回答1: You never really call doGet() or doPost() (the service() method will, and it is called by the Web container as you read in the lifecycle). The