由买买提看人间百态

topics

全部话题 - 话题: servlet
1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)
z*******g
发帖数: 132
1
看了些东东,还没明白, 我想import javax.servlet.* 怎么找不到呢。。。
————
在这个专题中我们由浅入深地向大家介绍Java Servlet的基本特征、开发环境的配置
以及Servlet的一些主要API类。
Servlet是一种独立于平台和协议的服务器端的Java应用程序,可以生成动态的Web页面
一、概述
Servlet是一种独立于平台和协议的服务器端的Java应用程序,可以生成动态的Web页面。
Servlet是位于Web 服务器内部的服务器端的Java应用程序,与传统的从命令行启动的
Java应用程序不同,Servlet由Web服务器进行加载,该Web服务器必须包含支持Servlet
的Java虚拟机。
Java Servlet 与 Applet 的比较:
相似之处:
* 它们不是独立的应用程序,没有main()方法。
* 它们不是由用户或程序员调用,而是由另外一个应用程序(容器)调用。
* 它们都有一个生存周期,包含init()和destroy()方法。
不同之处:
* Applet具有很好的图形界面(AWT),与浏览器一起,在客户端运行。
* Serv... 阅读全帖
t**********s
发帖数: 930
2
【 以下文字转载自 Programming 讨论区 】
发信人: tennisalways (tennisforever), 信区: Programming
标 题: Spring + Jersey 的 REST API, servlet context 能看到 Spring 的 root application context 里的bean吗?
发信站: BBS 未名空间站 (Fri Oct 9 17:57:56 2015, 美东)
比如这样的 web.xml

contextConfigLocation
/WEB-INF/root-context.xml



org.springframework.web.context.ContextLoaderListener
阅读全帖
t**********s
发帖数: 930
3
比如这样的 web.xml

contextConfigLocation
/WEB-INF/root-context.xml



org.springframework.web.context.ContextLoaderListener



REST-V1
com.sun.jersey.spi.spring.container.servlet.SpringServlet


contextConfigLocation... 阅读全帖
y***e
发帖数: 39
4
来自主题: Java版 - Servlet开发初步 [fwd]
Servlet开发初步
http://www.shinco.net/jjx/activeubb
Servlet是Java语言在WEB服务器端的一种应用技术,未来Servle
t将可能彻底取代
CGI。本讲座将具体介绍Servlet的概念、开发、调试以及相应的应用
实例。
一、什么是Servlet?
·Servlet是一种独立于平台和协议的服务器端的Java应用程序
,可以生成动态的
Web页面。
·Servlet是位于Web 服务器内部的服务器端的Java应用程序,
与传统的从命令行
启动的Java应用程序不同,Servlet由Web服务器进行加载,该Web服
务器必须包含支持
Servlet的Java虚拟机。
·Servlet与Web服务器的关系类似于Applet与Web浏览器的关系(
这也是为什么
Servlet技术被称为Servlet的原因),我们可以将Servlet想象成没有
前端界面
(faceless)的Applet。与Applet不同的是,由于Servlet运行在Web服
务器端,因此它是
一个可信赖的程序,不受到Java安全性的限制,拥有和普通Java应用
程序一样的权
z*********e
发帖数: 10149
5

这个是什么意思?不明白
我在tomcat manager里面看到的running app显示这个springapp的running 状态是
false,我在tomcat manager尝试start这个app的时候message: FAIL - Application
at context path /springapp could not be started
尝试访问localhost:8080/springapp/的时候,浏览器里显示
HTTP Status 404 - /springapp/
type Status report
message /springapp/
description The requested resource is not available.
Apache Tomcat/6.0.41
我的./springapp/war/WEB-INF/web.xml文件是

xmlns="http://java.sun.com... 阅读全帖
z*********e
发帖数: 10149
6
我在看这个tutorial
http://docs.spring.io/docs/Spring-MVC-step-by-step/part1.html
但是发现在web.xml里面加入了这一段dispatcher的话,这个app就在tomcat里面不能运
行,如果不用这一段dispatcher倒是可以,怎么解决这个问题?

springapp
org.springframework.web.servlet.DispatcherServlet servlet-class>
1


springapp
*.htm
z*********e
发帖数: 10149
7
我试了http://localhost:8080/springapp/hello.htm,也同样的错误
而且只要保留了这一段

springapp
org.springframework.web.servlet.DispatcherServlet servlet-class>
1


springapp
/*.htm

的话在 Tomcat Web Application Manager 的list applications里面能看到这个/
springapp的running状态是false。
试图在... 阅读全帖
s****d
发帖数: 13
8
来自主题: Java版 - Run Servlet with Tomcat
better setup it in the web.xml using something like below

HelloWorldExample
HelloWorldExample



HelloWorldExample
/HelloWorldExample


the
y***e
发帖数: 39
9
来自主题: Java版 - 理解Java Servlets [fwd]
理解Java Servlets
http://www.shinco.net/jjx/activeubb
为更加深入的理解Java servlets的意义,有关记者采访了Live
Software Inc.公司的CEO Paul Colton。Live Software公司主要从
事Java开发与研究,总部设在San Diego,Calif。Live Software开
发了Jrun,它是一个引擎,使标准的Web server能够运行Java
servlets。1999年,美国Allaire公司收购了Live
Software,并将Jrun继续作为一个独立的产品进行推广销售。尽管这
次专访的内容是在1997年发布的,但是对于我们认识Servlet技术依
然将有所帮助。
Java applet和Java servlet的区别是什么?
基本上讲,servlet是applet的反面。你可以将servlet想象成一个服
务器端的applet,Servlets在Web
Server上运行的方式同applets在Web浏览器上运行几乎相同。浏览器
可以直接发出一个请求执行一个servlet,它可以根
s******e
发帖数: 493
10
来自主题: Java版 - JavaServer Faces 和 Java Servlet
I do not think that you can compare JSF to servlet. JSF was introduced by
sun trying to compete with other application tier technologies such as
struts, spring mvc... Like all those web frameworks, jsf is based on Servlet
. Actually without jsp/servlet spec, none of those java based web frameworks
will ever work at all. JSF, not like other web frameworks, is designed
using page controller pattern, which is subtly different from front
controller patterns used by most other popular web frameworks.... 阅读全帖
b*g
发帖数: 644
11
By default, cookies are accessible to every HTTP request for
the current
directory, and any subdirectories. Now on most web servers
and servlet engines,
servlets are located in a special directory. For example,
when using
servletrunner (which ships with the Java Servlet Development
Kit), servlets
must be invoked under the /servlet/ directory.
http://webserver/servlet/servletname
If you want your cookies to be accessible elsewhere, you
must specify the
root path of your webserver, using the
javax
j******e
发帖数: 64
12
能够看到tomcat下所有的servlets-examples,在
/usr/local/tomcat/webapps/servlets-examples/ 下面,
于是自己写了一个最简单的HelloWorld.java,编译也可以
通过 javac -classpath /usr/loca/tomcat/servlet-api.jar HelloWorld.java
吧HelloWorld.java和.class都放在了
/usr/local/tomcat/webapps/servlets-examples/WEB-INF/classes
目录下,
其他的examples都能运行,为什么我的不行?
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorld extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServlet
j******e
发帖数: 64
13
我也更改了web.xml
加了

HelloWorld
HelloWorld
r*****s
发帖数: 985
14
Thanks for Qing DX's answer. It is really helpful.
Another urgent servlet question: The browser(IE) is somehow
caching the servlet output. There are some hyperlinks on the
output page created by serlvets. The hyperlink calls the
servlet itself or some other servlets. Due to the browser
caching problem, if the hyperlink has been clicked before,
the browser won't actually call the corresponding servlet,but
just return the previous caching pages, even the pages are
stale.
I tried to use
response.se
r***l
发帖数: 67
15
来自主题: Java版 - run servlet from command line?
The answer is Yes and No.
You can use mock object to simulate servlet environment and potentially
run/test your servlet without servlet container. However, that's more about
unit testing and it is an advanced topic.
Since you said you are new for Java, I do not want to confuse you here. So,
the answer is No. You can not run servlet from command line (without servlet
container). hehe

CGI
p***p
发帖数: 559
16
来自主题: Java版 - JB JAVA Bean,SERVLET位置一问
用JB做一个JSP,SERVLET东西。先建立一个WEB MODULE,JSP存在里面。然后建立JAVA
Bean,SERVLET这些,JB会保存在比如project/src/com/smth/javaweb/
里面。可是在JSP中如果使用com/smth/javaweb的BEAN或者SERVLET老是说找不到。我现在
用土办法,把所有BEAN或者SERVLET打成个JAR文件,然后引入LIB。
请问正确的该如何配置?
y***d
发帖数: 2330
17
I guess you need

FileCounter
/FileCounter
g*****g
发帖数: 34805
18
来自主题: Java版 - servlet的精华到底是啥?
I don't think servlet has anything to do with RMI.
Servlet is simply an entry point. You define the binding from url to servlet
in web.xml, and the web container intercepts the call and forwards to the
servlet.
z***s
发帖数: 3241
19
来自主题: Java版 - servlet到底是啥玩意
能不能这么理解,上层的struts,spring,jsf啥的,归根结底还是靠javax.servlet
里面的东西?所以struts被spring淘汰了,jsf完蛋了,但servlet一直离不了?
其实还是我疑惑很久的一个问题,啥是java ee?现在最新的servlet连web.xml都可以
不要了,用annotation来代替。这都是JEE的规范?
就是jee的servlet,web.xml由他们说了算,没法绕过去,而上层的ejb,jsf你可以不遵
守?

all
z****e
发帖数: 54598
20

springapp
/*.htm

这里是*.htm没发现?
一般来说不要映射到.htm或者.html这些上去
改成.do或者.others,随便你起,但是不要写成静态文件的后缀名
以免引发混淆
w**********k
发帖数: 1135
21
来自主题: BuildingWeb版 - servlet 是比较不错
小弟不才,最近很是研究了一下servlet,JSP,EJB一套东西。
别的好处还没有体会吧,如connection pool,load balance.
单单这个可移植性,就让我心倾不少。
我用servlet写了一套程序,已经在几个系统上移过来又移过去,
这些系统OS有Redhat 6.1,Windows 2000 Advanced server.
Servlet engine有Tomcat,Jserv&GNUjsp,WebSphere。
不用改一句程序,也不用重新编译,就可以移植成功。
这种Develop once,run everywhere的感觉很真是不错啊。
b*g
发帖数: 644
22
eading cookies from a servlet is quite easy. You can gain
access to any
cookies sent by the browser from the
javax.servlet.http.HttpServletRequest
passed to the servlet's doGet, doPost, etc methods.
HttpServletResponse
offers a method, Cookies[] getCookies() which returns an
array of Cookie
objects.
However, if no cookies are available, this value may be
null, so be sure
to check before accessing any array elements.
// Check for cookies
Cookie[] cookie_jar = request.getCookies();
// Check to see
m******t
发帖数: 2416
23

Butta... what I was thinking was, if you are not doing servlet
chaining, when you are calling another servlet, the instance of that
servlet you call is actually not the one taking and processing
incoming requests, and maybe not initialized at all.
Don't know, maybe we are talking about different things.
y*****p
发帖数: 733
24
来自主题: Java版 - J2EE tutorial servlet help!!
J2EE tutorial 中的那个bookstore 程序里,用了import javax.servlet.
为什么J2EE 的安装目录下 D:\Sun\AppServer 找不到servlet.jar?
那么asant build 是怎样能够编译文件生成 .class 文件的???
我现在想在 eclipse IDE 里面调试那些包含 import javax.servlet.的文件,
该如何设置?
万分感谢!!!
c*****s
发帖数: 214
25
main函数可以servlet上不行?这问题就差不多了。
可能的不同只剩下环境变量或classpath。
服务端那个被ServletException包着的错误八成是个NoClassDefError。
还是先找到服务端错误日志吧。
好奇的问, 你的Axis装在Tomcat上,怎么两端的错误都来自weblogic?
你确定http://as-dev.keas.ksu.edu:9080/axis是Tomcat上的Axis吗?
我觉得你完全可以先把你的Servlet在tomcat上调通再放到weblogic上。既然main函数都
可以运行了,应该很容易用servlet跑。



Axis)
c*****s
发帖数: 214
26
你是说Weblogic上跑客户端程序访问Tomcat上运行的Axis还是把Axis也搬到Weblogic上来
?前者应该不难,因为main程序已经可以运行,同样的代码放保证Classpath正确就行了
。可从你的stack trace上看服务端也是weblogic。
你说的Weblogic上的Application是什么形式?如果还是Servlet,我建议你先关掉weblog
ic把这个Servlet在Tomcat里调通。移植的时候如果还出错,只可能是实施错误。
另外如果想找日志,可以在$BEA_HOME/user_projects//logs和$BEA_HOME/use
r_projects//下看看。

多谢cyclops的帮忙。我的Axis的确装在Tomcat上。我们现在要用WEBLOGIC上的APPLICATI




里就不行?错误里和weblogic.servlet.internal.ServletStubImpl.invokeServlet
d********r
发帖数: 199
27
Servlet的IO吞吐瓶颈在哪里?为什么测下来只有3M bytes 左右?
想测一下Tomcat servlet 的输出能力,就写了如下代码段:
1. Server: P4 3.0G, 1G DDR400 memory
输出一个100M bytes的http 文本。servlet key code segment 如下:
l*****b
发帖数: 82
28
1. 用Junit模拟多线程Servlet访问
2. 模拟真实Servlet容器处理多线程Servlet访问但不依赖容器
大概就是模拟完全production环境。
请问各位高手们有什么建议? 谢谢。
l*****b
发帖数: 82
29
am testing the servlet application using tomcat and customized multithreded
test clients. I try the following different scenarios - synchronize or not
the servlet method. In client side, I generate 200 concurrent requests to
this servlet. There are quite different CPU usage in this scenarios: non-
synchronized one use much more CPU (almost 100%) than synchronized (as usual
). Could anyone advise me what's happened there and why has that different?
e.g.
public TestServlet .....{
public void doGet
m***i
发帖数: 213
30
标题没法描述清楚。问题是这样的:
本来是jsp的form submit到servlet,target是一个iframe,这样servlet可以forward
到另一个jsp,显示会用iframe嵌入。现在不用iframe,改用来实现嵌入,这样
就不能用target了,servlet应该怎么做,才能返回object替代iframe和target的功能
呢?
z****e
发帖数: 54598
31
jsp就是servlet
反过来说也差不多
jsp诞生的目的就是用一种更为直观的方式来编写网页
servlet就是一个服务器端动态生成网页的一个程序段
在容器中运行,真正运行在服务器端的软件不是servlet,是容器
applet是一个客户端浏览器上运行的程序
类似于flash
u*e
发帖数: 965
32
写了一个应用。 JSP得到输入的serial num --> Servlet访问数据库 --〉结果通过
socket连接打印机打印。
运行没有问题, 但是10秒内再输入另一个serial num, 就出现超时。半分钟后,就没
有问题。在main()里运行试验过了,多频繁都没有问题。
请帮忙看看,谢谢了。
------------------------------------------------
java.net.ConnectException: Connection timed out: connect
java.net.DualStackPlainSocketImpl.connect0(Native Method)
java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl
.java:69)
java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:
337)
java.n... 阅读全帖
g*****g
发帖数: 34805
33
REST WS is a language neutral spec. You don't have to use Java, even you are
using java, you don't have to use doGet or doPost. Servlet 3.0 introduces
asynchronous servlet. vertx doesn't use servlet at all.
e*****t
发帖数: 1005
34
来自主题: Java版 - JavaServer Faces 和 Java Servlet
servlet is the underlying technology and you'd better get a grasp of it. But
you rarely need to write your own servlet.
JSF is something built on top of servlet, which is more important than servl
et itself. If you want to work with a JavaEE webapplication. You probably wa
nt to pay more attention to JSF.
g*****g
发帖数: 34805
35
来自主题: Java版 - servlet到底是啥玩意
Not at all, servlet is the foundation of many web frameworks. e.g. Spring
MVC which still has largest market share for Java web frameworks to date.
Servlet 3.0 adds async support, servlet 3.1 adds non-blocking.
g*****g
发帖数: 34805
36
来自主题: Java版 - servlet到底是啥玩意
你写网站不一定要用 servlet,甚至不一定要 java. 但 spring mvc是基于 servlet的。
servlet就是个规范,写应用和写 web app server的可以分开。
t**********s
发帖数: 930
37
估计红岩说的情况如果用Spring自己的 dispatcherservlet应该没问题。但混用Jersey
的 支持Spring的servlet(com.sun.jersey.spi.spring.container.servlet.
SpringServlet) 不行。
不过发现不import, 而是扫描root context 里的bean( -package="xxx.xxx"/>也work, 而且root context 里的bean,不会在servlet context
里再生成一遍。
e****e
发帖数: 19
38
I have the web server running. Also have the java source
codes of the servlet.
How to publish the servlet so browsers can access it?
Thanks.
z**k
发帖数: 65
39
【 以下文字转载自 Programming 讨论区,原文如下 】
发信人: zack (会飞), 信区: Programming
标 题: 急!在线等---从Servlet调用AXIS的Web Service 遇到问题!
发信站: Unknown Space - 未名空间 (Thu Oct 7 14:25:33 2004) WWW-POST
各位,请一定帮帮忙,老板在催活!万分感激!
I met some difficulties when trying to call a simple web service
function from a servlet / jsp. Please give me some help or hints as
possible as you could. Thanks a lot.
I deployed a simple web service function on Tomcat/Axis SOAP server.
The .wsdl file looks fine. The only function of the web service i
z**k
发帖数: 65
40
【 以下文字转载自 Programming 讨论区,原文如下 】
发信人: zack (会飞), 信区: Programming
标 题: 急!在线等---从Servlet调用AXIS的Web Service 遇到问题!
发信站: Unknown Space - 未名空间 (Thu Oct 7 14:25:33 2004) WWW-POST
各位,请一定帮帮忙,老板在催活!万分感激!
I met some difficulties when trying to call a simple web service
function from a servlet / jsp. Please give me some help or hints as
possible as you could. Thanks a lot.
I deployed a simple web service function on Tomcat/Axis SOAP server.
The .wsdl file looks fine. The only function of the web service i
z**k
发帖数: 65
41
【 以下文字转载自 Programming 讨论区,原文如下 】
发信人: zack (会飞), 信区: Programming
标 题: 急!在线等---从Servlet调用AXIS的Web Service 遇到问题!
发信站: Unknown Space - 未名空间 (Thu Oct 7 14:25:33 2004) WWW-POST
各位,请一定帮帮忙,老板在催活!万分感激!
I met some difficulties when trying to call a simple web service
function from a servlet / jsp. Please give me some help or hints as
possible as you could. Thanks a lot.
I deployed a simple web service function on Tomcat/Axis SOAP server.
The .wsdl file looks fine. The only function of the web service i
t*******y
发帖数: 57
42
来自主题: Database版 - servlet调用sql 访问oracle的问题
这几天真是见了鬼了
在Linux下单独写个standalone的java程序用JDBC访问oracle一点问题都没有
换写成servlet来通过JDBC访问oracle竟然只能做"select .."这样的sql访问
用什么insert/update/desc之流的sql命令通通给我出错,
说什么java.sql.SQLException: SQL string is not Query
ft,明明直接把那些sql命令放入sqlplus执行和放在standalone的java程序里面
执行一点问题都没有.google了半天没有啥结果.
这个到底啥原因有人知道么?难道用servlet调用jdbc数据库还有权限限制?
用perl写的cgi调用数据库也一点问题都没有呀.
f****d
发帖数: 1
43
来自主题: Java版 - How do a Servlet sent a Applet?
How do a Servlet sent a Applet?
My pc:win 98 ,apache 1.3.6(win) ,AJserv 1.0
JDK 1.1.8 ,JSDK 2.0
I write a simple Servlet ,all of source:
b*g
发帖数: 644
44
HTTP is a stateless protocol, which makes tracking user
actions difficult.
One solution is to use a cookie, which is a small piece of
data sent by a
web browser every time it requests a page from a particular
site. Servlets,
and CGI scripts, can send cookies when a HTTP request is
made - though as
always, there is no guarantee the browser will accept it.
Cookies are represented by the javax.servlet.http.Cookie
class. Cookie has
a single constructor, which takes two strings (a key and a
value).
/
h******m
发帖数: 10
45
来自主题: Java版 - Run Servlet with Tomcat
Hi guys,
I installed tomcat 4,the server works fine (shows up the test page),and the
servlet code compiles, but I can't load it with local:8080
That's what I did:create a directory of 'classes' under
webapps/Root/WEB-INF/,then put my .class file there,but when I tried
http:localhost:8080/servlet/HelloWorld, it doesn't load,always shows up
....file not available, seems I put the .class into a wrong place.
What's wrong with it?
Thanks.
s*r
发帖数: 1903
46
help, friends:
I can start the tomcat as a standalone server and run the examples. For
simplicity, I just put my files in examples folder so that I do not need to
change server.xml and web.xml.
I can not compile the servlet, it alwasy says that the javax.servlet.* does
not exist. How can I deal with it? Thank you very very much.
l*********r
发帖数: 80
47
【 以下文字转载自 JobHunting 讨论区,原文如下 】
发信人: littlelover (大肚子情剩), 信区: JobHunting
标 题: Urgent Help needed about Java Servlet?
发信站: Unknown Space - 未名空间 (Sat Oct 25 17:13:21 2003) WWW-POST
UserAdmin.java is in C:\jwsdp-1.3\webapps\HW3example\WEB-INF\classes
hw1_lib.jar is in C:\jwsdp-1.3\webapps\HW3example\WEB-INF\lib
我是这样compile的:
C:\jwsdp-1.3\webapps\HW3example\WEB-INF\classes>javac -classpath
C:\jwsdp-1.3\we
bapps\HW3example\WEB-INF\lib\hw1_lib.jar;c:\jwsdp-1.3\common\lib\servlet-api.j
ar
UserAdmin.ja
t********k
发帖数: 808
48
哪位用过jspSmartUpload包?
好象只能在JSP里进行文件上传和下载,
不能在Servlet进行处理,
哪位有在servlet上传文件的包?
t********k
发帖数: 808
49
几个JSP页面向servlet发出请求
处理完后要运行不同的JSP页面(就是那个JSP页面相同目录里的另外一个页面,文件名一样)
不想再在jsp里传进一个标志符,再在servlet里进行判断应该执行哪个页面
比如1.jsp调用了/servlet1
在servlet1里,怎么知道1.jsp的路径呢?
我要在servlet1里调用1.jsp相同目录下的另一个jsp页面
谢谢
w*r
发帖数: 2421
50
来自主题: Java版 - JB JAVA Bean,SERVLET位置一问
If you wish to use those objects, you need import the path. You should know
that JSP is nothing but a 'servlet', basically, the jsp will be translated
into a servlet while it is compiled by the J2EE container. So, it's final
representation is a class.
Import in JSP is: <%@ page import="java.lang.*" %>
Do not forget to put double quotes on the package name.

1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)