简体   繁体   English

Java Web应用程序

[英]Java Web Application

I am interested in creating a simple web application that will take in user input, convert it to an XML file and send the file to a database. 我对创建一个简单的Web应用程序感兴趣,该应用程序将接受用户输入,将其转换为XML文件,然后将该文件发送到数据库。

Coding wise I feel I am okay, it is just the general setup and what implementation to use I am a bit unsure of. 编码方面,我觉得我还可以,这只是常规设置以及我不确定使用哪种实现。

At the moment I have a JSP page containing a form, the user fills out the form and on submit a POST method is sent to a servlet , in the servlet doPost() method the servlet is instantiating a java object and passing it the user inputted data. 目前,我有一个包含表单的JSP页面,用户填写表单,并在submit POST method其发送到servlet ,在servlet doPost()方法中,servlet实例化一个java object并将用户输入的内容传递给它数据。 The java object then writes that data to an XML file and sends it to the database via REST . 然后,java对象将该数据写入XML file并通过REST将其发送到数据库。

All I would be interested to know is if this the standard/optimal way of creating such a web application. 我只想知道这是否是创建此类Web应用程序的标准/最佳方式。

Any and all feedback is appreciated. 任何和所有反馈表示赞赏。

Thanks 谢谢

For a "simple webapplication" this high level approach looks fine in general. 对于“简单的Web应用程序”,这种高级方法通常看起来不错。 However, if you want more critical feedback, you'd need to give more details about the low-level approach. 但是,如果您需要更多重要的反馈,则需要提供有关低级方法的更多详细信息。 It may for example happen that it isn't memory efficient and thus may break when the webapp is been used by over 10 users concurrently, just to give an example. 例如,可能发生这种情况,即内存效率不高,因此当10个以上的用户同时使用webapp时可能会中断,仅举一个例子。

I only question the choice for the GET method. 我只质疑GET方法的选择。 You'd normally only use it to retrieve data ( SELECT ), not to create/alter data ( INSERT/UPDATE/DELETE ). 通常,您只用它来检索数据( SELECT ),而不用创建/更改数据( INSERT/UPDATE/DELETE )。 For that you'd normally use POST , so that no one can execute it "accidently" by just clicking a (bookmarked) link. 为此,您通常使用POST ,因此没有人可以通过单击(带书签)链接来“意外”执行它。 Changing GET to POST isn't that hard, add method="post" to the <form> element and rename doGet() to doPost() . GET更改为POST并不难,将method="post"添加到<form>元素并将doGet()重命名为doPost()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM