Модераторы: LSD, AntonSaburov
  

Поиск:

Ответ в темуСоздание новой темы Создание опроса
> Как запустить сервлет, Как запустить сервлет 
:(
    Опции темы
Гость_Cont
Дата 13.9.2003, 21:42 (ссылка)    |    (голосов: 0) Загрузка ... Загрузка ... Быстрая цитата Цитата


Unregistered











На сервере mycgiserver.com есть образец
HelloWorldServlet.class, который непонятно как запустить.
Я его скачал , откомпилировал, загрузил и не могу вызвать.
Никаких папок типа webapp там нет. Что делать?
HEPL!!!PLEASE!!!
  Вверх
Sun
Дата 15.9.2003, 11:03 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Account removed
***


Профиль
Группа: Экс. модератор
Сообщений: 1611
Регистрация: 14.8.2002

Репутация: 8
Всего: 48



А это ты пробовал?
Цитата

1. I have the source files ready, what now?
The next step is compiling your servlet. You can compile it online by using 'javac online' in this area.
Another possibility is compiling them on your local machine. For being able to do so you'll need the Java Development Kit and Java Servlet Development Kit (JSDK).

2. How do I start my servlet?
For starting your servlet you need to use the account path to your servlet in conjunction with the servlet URL. For example, if you want to execute helloworld.class the URL would be:

http://www.mycgiserver.com/servlet/USERNAME.helloworld

We used to have a wrapper for being able to call servlets directly via the classfile, however this is disabled again as it created a conflict with java applets.

3. My servet is giving me a wrong classname error. Why?
What you've to take care about is the package name which has to reflect your username and the path where the servlet is stored.
Supposing that the username is 'testuser' and the path where the servlet class is stored is 'apps/work/test.class' (relative to your account root directory). Your package name would then look like the following:

testuser.apps.work

Set this package name, compile your servlet again and it will work.

4. I have my servlets ready in a jar file, how can I execute them?
You can't! If you want to use jar files with java you normally have to add the particular archive to the classpath. However this is not possible in this case, you can't modify the systems classpath.
If you simply want to be able to use a java class library stored in a jar which is freely available through the internet simply let us know and we'll install it in the main class repository.

5. Do I have my own servlet ZONE?
No, our members are sharing a single zone, the servlet engine wouldn't be able to cope with such a huge number of zones otherwise.

6. I want to write into the log with my servlet, how can I do that?
For writing log entries, use the log function as in the following example, which will writes the message 'MY PERSONAL LOG ENTRY' into the log:

public void doGet (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
...
this.getServletContext().log("MY PERSONAL LOG ENTRY" + ": " + request.getServletPath());
...

If you want to log the content of a variable for example, the line would look like the following:

String strHelloTo = "World";

this.getServletContext().log(strHelloTo + ": " + request.getServletPath());




--------------------
Account removed
PM MAIL   Вверх
Гость_Cont
Дата 15.9.2003, 16:18 (ссылка)    |    (голосов: 0) Загрузка ... Загрузка ... Быстрая цитата Цитата


Unregistered











1.Я создал структуру
user(корень)
………………
html файлы
………………
WEB-INF
web.xml
classes
user
HelloWorldServlet.class
В serv.html в форме прописал
<form action="/avart/HelloWorldServlet">
В web.xml
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc. //DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>
<display-name>
HelloWorldServlet
</display-name>

<description>
HelloWorldServlet
</description>

<servlet>
<servlet-name>HelloWorldServlet</servlet-name>
<description>
my servlets
</description>
<servlet-class>
user.HelloWorldServlet
</servlet-class>
<servlet-mapping>
<servlet-name>HelloWorldServlet</servlet-name>
<url-pattern>/HelloWorldServlet</url-pattern>
</servlet-mapping>
</servlet>
<web-app>

Сервлет откомпилировал в package user.
Это все по учебнику.
2. Пробовал после компилирования в JBuilder скачивать
в корень user на сервере содержимое папки defaultroot.
Там находится
WEB-INF
web.xml
classes
user
HelloWorldServlet.class


Вот web.xml от JBuilder:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<servlet>
<servlet-name>helloworldservlet</servlet-name>
<servlet-class> user.HelloWorldServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>helloworldservlet</servlet-name>
<url-pattern>/helloworldservlet</url-pattern>
</servlet-mapping>
</web-app>

В браузере набираю
http://www.mycgiserver.com/ user.helloworld

Ничего не получается.
HELP!!!PLEASE!!!




  Вверх
  
Ответ в темуСоздание новой темы Создание опроса
Правила форума "Java"
LSD   AntonSaburov
powerOn   tux
javastic
  • Прежде, чем задать вопрос, прочтите это!
  • Книги по Java собираются здесь.
  • Документация и ресурсы по Java находятся здесь.
  • Используйте теги [code=java][/code] для подсветки кода. Используйтe чекбокс "транслит", если у Вас нет русских шрифтов.
  • Помечайте свой вопрос как решённый, если на него получен ответ. Ссылка "Пометить как решённый" находится над первым постом.
  • Действия модераторов можно обсудить здесь.
  • FAQ раздела лежит здесь.

Если Вам помогли, и атмосфера форума Вам понравилась, то заходите к нам чаще! С уважением, LSD, AntonSaburov, powerOn, tux, javastic.

 
0 Пользователей читают эту тему (0 Гостей и 0 Скрытых Пользователей)
0 Пользователей:
« Предыдущая тема | Java: Общие вопросы | Следующая тема »


 




[ Время генерации скрипта: 0.0676 ]   [ Использовано запросов: 22 ]   [ GZIP включён ]


Реклама на сайте     Информационное спонсорство

 
По вопросам размещения рекламы пишите на vladimir(sobaka)vingrad.ru
Отказ от ответственности     Powered by Invision Power Board(R) 1.3 © 2003  IPS, Inc.