java-ee

How can I manually load a Java session using a JSESSIONID?

╄→尐↘猪︶ㄣ 提交于 2019-12-17 15:27:44
问题 I have a servlet which handles a multipart form post. The post is actually being made by a Flash file upload component embedded in the page. In some browsers, the Flash-generated POST doesn't include the JSESSIONID which is making it impossible for me to load certain information from the session during the post. The flash upload component does include cookie and session information within a special form field. Using this form field, I can actually retrieve the JSESSIONID value. The problem is

Atomikos vs JOTM vs Bitronix vs? [closed]

北战南征 提交于 2019-12-17 15:27:33
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 6 years ago . I am new to JTA and it's underlying transaction managers. Can anyone explain the pros/cons of each of these? Feel free to add others I didn't list in title. Also, don't the major applications servers (WebSphere, JBoss, Glassfish) have their own JTA compliant transaction

Spring 3.0 vs Java EE 6.0 [closed]

与世无争的帅哥 提交于 2019-12-17 15:16:50
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . I'm confronted with a situation... I've been asked to give an advise regarding which approach to take, in terms of Java EE development

Why does Eclipse propose “Object” as default mapping type for datatype “Text”?

梦想的初衷 提交于 2019-12-17 14:56:40
问题 When generating JPA Entities from tables with Eclipse (Juno 4.2 for Java EE Developers) it proposes Object as default mapping type for properties I set to be Text . That is quite annoying as I would have to set them all to String manually. Has someone encountered that kind of problem and knows what to do? Is this a bug? Eclipse Indigo does not behave like that. This is the /runtime/vendors/MySql_5.1/MySql_5.1.xmi from org.eclipse.datatools.enablement.mysql.dbdefinition_1.0.4.v201109022331.jar

Replace characters with HTML entities in java

孤者浪人 提交于 2019-12-17 14:53:17
问题 I want to replace certain characters with their respective HTML entities in an HTML response inside a filter. Characters include < , > , & . I can't use replaceAll() as it will replace all characters, even those that are part of HTML tags. What is the best approach for doing so? 回答1: From java you may try, Apache Commons Lang (legacy v2) StringEscapeUtils.escapeHtml(). or with commons-lang3: StringEscapeUtils.escapeHtml4(). Please note this also converts à to à & such 回答2: If you're using a

Call a servlet on click of hyperlink

旧巷老猫 提交于 2019-12-17 11:04:09
问题 Is there a way to call a Java Servlet on click of hyperlink without using JavaScript? 回答1: Make the hyperlink have a URL that you have a servlet mapping defined for in the web.xml file. The servlet-mapping element defines a mapping between a servlet and a URL pattern. The example below maps the servlet named myservlet to any URL that starts with /foo : <servlet> <servlet-name>myservlet</servlet-name> <servlet-class>com.stackoverflow.examples.MyServlet</servlet-class> </servlet> <servlet

Inject @EJB bean based on conditions

ε祈祈猫儿з 提交于 2019-12-17 10:54:16
问题 A newbie question: is there anyway that I can inject different beans based on a condition that I set in a properties file. Here's what I want to achieve: I set some value in properties file. If it's true, then I want to public class MyClass{ @EJB private MyBean bean; } if it's false, then public class MyClass{ @EJB private MyBean2 bean2; } Is this doable? 回答1: As Gonzalo said, you would firstly need to specify the common interface of the bean if you want to declare it as a class field and use

Root URl of the servlet

梦想与她 提交于 2019-12-17 10:52:24
问题 I want to get the root url of my web application from one of the servlet. If I deploy my application in "www.mydomain.com" I want to get the root url like "http://www.mydomain.com". Same thing if I deploy it in local tomcat server with 8080 port it should give http://localhost:8080/myapp Can anyone tell me how to get the root URL of my web application from servlet? public class MyServlet extends HttpServlet { @Override protected void doPost(HttpServletRequest request, HttpServletResponse

Stateful EJBs in web application?

风流意气都作罢 提交于 2019-12-17 10:34:33
问题 I never used stateful EJBs. I understand that a stateful EJB can be useful with a java client. But i wonder: in which case to use them on a web application? And how? Should we put these stateful beans in Session (because of stateless http)? Is it a good practice? (without debating too much about stateful vs stateless) 回答1: Funny enough, it's a 2nd question on SFSB and web app for the day, while this topic is usually not that common. in which case to use them on a web application? The

What is meant by abstract=“true” in spring?

最后都变了- 提交于 2019-12-17 10:33:36
问题 Abstract classes cannot be instantiated in java. But spring says something like bean creation with abstract="true" . If a state of an abstract class is initialised only by its child class instance(i guess i am right), then if i need to use that attribute inside the method which is defined in the abstract class then... is there a possibility for it? I have a set of code as follows: class abstract A { private Something somethingObj; // getters and setters are present. public void logSomething()