总体而言,您的方法非常笨拙,您可以稍微修改它。
I have an HTML page which posts its form data (DB credentials) to a servlet.
In the servlet, I create a connection using the credentials.
建立连接。检查连接是否建立
Now I want to display an HTML page which will accept the details of a record to be entered.
I want to then retrieve this data and enter it into the DB
如果确定它重定向到你需要创建一个HTML页面来接受来自用户的输入,并将其张贴到servlet第二HTML页面。你甚至可以将它发布到同一个servlet和使用输入字段处理它们,你甚至可以将它发布到另一个servlet
Will this second post start a new servlet instance?
没有Web容器犯规创建一个新的对象,每次,而这股同样的实例,直到应用程序正在运行
而我不知道你为什么要显示servlet内的html内容。 JSP仅用于此目的。
希望它有帮助!