Answer the question
In order to leave comments, you need to log in
Need J2EE advice?
Good afternoon, Habrasoobshchestvo!
It is very inconvenient to ask, but still ... I do not study server Java very much. Since I don’t have a mentor who would beat hands, shout and scold for bydlokoding, I ask you to look at my craft with an experienced eye.
Actually, you can find it here .
I would like to hear all the moments where I do wrong and wrong. More constructive criticism and links to how to do it right. Interested in everything - from the correctness of the namespace, to moments where the system is not optimized. And also your advice / wishes / comments.
Thank you very much in advance!
Answer the question
In order to leave comments, you need to log in
(I only looked at MakeTransactionServlet and UMakeTransactions.jsp, other files should be similar).
Your model (DB), view (JSP) and controller (servlet) are not clearly separated.
Now it happens like this:
The servlet acts as a controller responsible for processing requests and creating any beans needed by the JSP page. The controller is also responsible for deciding which JSP page to forward the request. The JSP page retrieves objects created by the servlet and extracts dynamic content for insertion within a template.In general, of course, it would be nice to study the article in its entirety.
request.setAttribute("resultsForJsp", bean)
getServletContext().getRequestDispatcher("/WEB-INF/jsp/myView.jsp").forward(request, response)
/WEB-INF/...
is available only to “friends” from inside the servlet container, the browser will not get there in any way - therefore, checking the incoming data (including access rights) is not needed: the servlet has already done it.<c:forEach var='item' items='${resultsForJsp.items}'>
<option value="<c:out value='${item.item_id}'/>"><c:out value='${item.item_name}'/>
</c:forEach>
Use maven (parent pom and children for sub-projects). Use spring. If you want to do something for the web, I advise Play! it will be easier to get started with it. Well, good luck!
1. As already advised - master maven2: split the project into modules with different responsibilities; move resources to resource folders, use jetty maven plugin to debug the entire web application, etc. etc. A lot of features and additional plugins for literally all occasions.
2. It is not necessary to store in SVN what can be generated from source codes - for example, Eclipse folders. Project files for any popular IDE can be generated from maven2 pom-s. Likewise with dependencies. maven2 will download the jars you need for you, put them in the WEB-INF/lib folder and build war. For information - maven.apache.org/guides/getting-started/index.html
3. Package naming. It's standard practice to create packages like com.mycompany.myproject.orm, com.mycompany.myproject.util, etc., don't be afraid to nest.
4. Naming class fields, user_id is a bad idea, use camel case everywhere. In general, learn and adhere to Java Code Conventions java.sun.com/docs/codeconv/CodeConventions.pdf
5. For a small test project, I recommend using an embeddable database instead of Oracle, such as HSQLDB
On the Downloads tab, only a JPG with a database schema and an archive with an sql script.
I didn't see J2EE there.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question