【问题标题】:Uploading multiple files using file upload control in apache tomcat使用apache tomcat中的文件上传控件上传多个文件
【发布时间】:2011-07-31 14:17:12
【问题描述】:
我是 apache tomcat 的新手。我在我的 Windows 机器上运行 apache tomcat。我有一个包含文件上传控件的 html。使用它我应该允许其他人上传文档。我在同一个 html 中有另一个 div 来列出上传的文件。在列出文件时,我想显示其上传的 IP 地址。请注意,上传的文档应存储在我的本地驱动器中。指导我这样做..
我想知道如何在 apache tomcat 中添加 servlet 和 jsp 以及如何在 html 中调用它。
提前谢谢...
【问题讨论】:
标签:
java
html
apache
jsp
servlets
【解决方案1】:
你可以通过 servlet 获取 ip
// This method is called by the servlet container to process a GET request.
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
// Get client's IP address
String addr = req.getRemoteAddr(); // 123.123.123.123
// Get client's hostname
String host = req.getRemoteHost(); // hostname.com
}
可以显示在html页面中,也可以保存在数据库中