摘要:
摘要
在为服务器端组件编程时,你很可能要从相对于web根的路径来取得某个文件的真实路径,但此文件实际上在站点的一个虚拟路径上。
什么是虚拟路径?
在一个web服务器上,虚拟路径将物理上分离的各文件组合在一起,放在同一个站点路径上,在应用服务器上,每个应用定位于其自己的虚拟路径上,实际上相互之间有着完美地分离。
getrealpath()方法
jsp se......
摘要: 随着世界范围内internet环境的形成,全球正进入一个以网络为中心的计算时代。web模型是在传统的c/s模型的基础上发展起来的一种新的browser/server计算模式。browser/server模型简化了c/s中的客户端,客户端只需装上操作系统、网络协议软件及浏览器;而服务器端则集中了所有的应用逻辑,开发、维护等几乎所有工作也都集中在服务器端。这时的客户机被称为瘦客户机,服务器被称为肥......
如何在Web页上实现文件上传
public class uploadservlet extends httpservlet
{
//default maximum allowable file size is 100k
static final int max_size = 102400;
//instance variables to store root and success message
string rootpath, successmessage;
/**
* init method is called when servlet is initialized.
*/
public void init(servletconfig config) throws servletexception
{
super.init(config);
//get path in which to save file
rootpath = config.getinitparameter("rootpath");
if (rootpath == null)
{
rootpath = "/";
}
/*get message to show when upload is complete. used only if
a success redirect page is not supplied.*/
successmessage = config.getinitparameter("successmessage");
if (successmessage == null)
{
successmessage = "file upload complete!";
}
}
/**
* dopost reads the uploaded data from the request and writes
* it to a file.
*/
public void dopost(httpservletrequest request,
httpservletresponse response)
{
servletoutputstream out=null;
datainputstream in=null;
fileoutputstream fileout=null;
try
{
/*set content type of response and get handle to output
stream in case we are unable to redirect client*/
response.setcontenttype("text/plain");
out = response.getoutputstream();
}
catch (ioexception e)
{
//print error message to standard out
system.out.println("error getting output stream.");
system.out.println("error descriptio...
下一页 摘要:
java server page(简称jsp),和asp、php一样都是网络编程语言,只不过在jsp页面中插入的脚本代码是java语句片段。要利用jsp编写应用,首先,必须要有一个能执行jsp脚本的web服务器,可以在原有的apache、iis或pws服务器的基础上建立,不过有许多技术上的问题。建议刚接触jsp的虫们,还是白手起家,直接安装一个专门支持jsp的web服务器,以免节外生枝......