Skip to main content

Posts

Showing posts with the label java-ee

Eclipse as an IDE - What do you find missing as a beginner in Java?

I am working on a solution that aims at solving problems that newbie programmers experience when they are "modifying code" while bug fixing / doing change requests, on code in production. Eclipse, as we all know is a great IDE. Features such as Code Completion, Open Declaration, Type Hierarchy, Package Explorer, Navigator, Finding References etc aids people in fixing things quicker compared to say using something like Textpad.

what is j2ee/jee?

OK stupid question but... I realize that literally it translates to java 2 enterprise edition. What I'm asking is what does this really mean? when a company requires j2ee experience what are they really asking for? experience with ejb's? experience with java web apps? I suspect that this means something different to different people and the definition is subjective, so please try to upvote rather than reposting something already in another answer.

Respond encoding of Google App Engine(can not change response encoding)

public class FeedUpdaterServlet extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { PrintWriter out = resp.getWriter(); req.setCharacterEncoding("utf-8"); resp.setLocale(Locale.TAIWAN); resp.setContentType("text/html; charset=utf-8"); resp.setCharacterEncoding("utf-8"); resp.getWriter().println("Hello, world!!@!"); out.println("我是人"); //some chinese character out.println(resp.getCharacterEncoding()); out.flush(); out.close(); } } web xml <locale-encoding-mapping-list> <locale-encoding-mapping> <locale>zh_TW</locale> <encoding>utf-8</encoding> </locale-encoding-mapping> </locale-encoding-mapping-list> Output: Hello, world!!@! ??? ISO-8859-1 It seems that the encoding of the respond can not be changed, what is happening???

Image is not displayed on reterival

I have a table with Images stored in it as BLOB. I'm using JPA/Hibernate. So, that Images are mapped to a bean field with type blob. Now my Spring controller is returning entire list of bean (each object of this bean has a blob object) to my jsp. I want to display all the images on that jsp. So, I tried to use some thing like this on my jsp, <c:forEach items="${itemList}" var="item" varStatus="status" > <img src="<c:out value="${item.image}" />"/><br/> /*<img src="${item.image}"/> */ </c:forEach> but that is not working. Instead of getting the list of images displayed on jsp , I 'm getting the class name, when I view the page source I saw something like this <img src="java.object.serilizableBlob@2134"/> Please help me delve with the problem. How can I display all the images on same jsp.

browser keeps on looking for the data but never fetches it

Following is a snippet that is meant to fetch the data from the database. But when i click the submit button to see the data, the browser keeps on looking for the data but never displays anything (the browser doesn't show the next page but keeps on looking on the same page) . I don't know what the problem is. Snippet that fetches the data : public void doGet(HttpServletRequest request,HttpServletResponse response) throws IOException,ServletException { try { Context context = new InitialContext(); DataSource dataSource = (DataSource)context.lookup("java:comp/env/jdbc/MyDatasource"); Connection connection = dataSource.getConnection(); String sqlStatement = "SELECT * FROM INFORMATION"; PreparedStatement statement = connection.prepareStatement(sqlStatement); ResultSet set = statement.executeQuery(); PrintWriter writer = response.getWriter(); response.setContentType("text/plain");

How should I be creating classes when doing TDD

I have started doing TDD and I am unsure if I am doing it correctly. I have made a Question class and a QuestionTest. The Question class has an addAnswer method that takes an instance of the Answer class. Now, should I be creating only the class Answer and use the default constructor. Or should I be making the Answer class and also provide the constructor with parameters? question.addAnswer(new Answer("Some", "Argument that I know I will use")); or: question.addAnswer(new Answer()); It is probably the last one where I write only as much as I need to proceed.

Why this table In-Cell editor, doesnt work?

I am trying to figure out, how the primefaces in-cell editor works. For some reason, it does not work. I just see it activating and also i can type, but the values do not change. What is missing? <?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:p="http://primefaces.org/ui" xmlns:f="http://java.sun.com/jsf/core"> <h:form> <p:dataTable id="allSubjects" var="subject" value="#{subjectControllerUpdate.retrieve()}" paginator="true" rows="7" > <p:column headerText="Name" sortBy="#{subject.name}" style="width:200px" > <p:cellEditor>

JSF2.0 - InputTextArea inside Dialog cannot be retrieved via Jquery during the dialog"s onShow event

I have the following dialog inside my .xhtml page. <p:dialog widgetVar="exampleDialog" onShow="fillTextArea()" > <p:tabView id="tabView"> <p:tab id="exampleTab" title="Example"> <p:inputTextarea id="someInputTextArea" autoResize="false" value="" /> </p:tab> </p:tabView> </p:dialog> The dialog is shown when a button is clicked. The fillTextArea javascript function is defined inside script tags at the head of the document. function fillTextArea() { console.log(jQuery("textarea[id='someInputTextArea']")); // logs empty array [] console.log($("[id='someInputTextArea']")); // logs empty array [] jQuery("textarea[id='someInputTextArea']").val('xxx'); // does nothing } What's the problem? Why can't I retrieve the input text area? In