Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > How to: call a Servlet within a java class

Reply
Thread Tools

How to: call a Servlet within a java class

 
 
Marco
Guest
Posts: n/a
 
      05-12-2004
Hi to all!

I have an Apache Tomcat 5.0.19 Server installed on a machine in my network
(ip address: 192.168.0.211, port 8080)

I've a Servlet running on it. FileUploadServlet uses "FileUpload package" from
Apache Jakarta Project (see: http://jakarta.apache.org/commons/fileupload/), in
order to implement Upload services

I'm able to call this Servlet from a jsp test page: FileUploadServletTest.jsp
is on 192.168.0.211 and I can call it from any machine in my network, calling
http://192.168.0.211:8080/UploadTest...ervletTest.jsp

The Servlet works fine!

Now: I want to call this Servlet from a java class. This class is called
UploadStockFile.java and is part of a standalone Swing-based java program.
This program is running on a machine in my network (ip: 192.168.0.112)

How can I do this? How can I call this servlet from a java class?

Any idea greatly appreciated

Thanks and sorry for bad english

Bye

Marco
 
Reply With Quote
 
 
 
 
Davor Cengija
Guest
Posts: n/a
 
      05-12-2004
Marco wrote:
> How can I do this? How can I call this servlet from a java class?


I guess you need to open an URL (which happens to be a servlet in your case)
and not a servlet directly (calling yourServlet.service() or something)

Use an HTTP client, e.g. the one found at http://jakarta.apache.org/commons
or play with java.net.URLConnection,
http://java.sun.com/j2se/1.4.2/docs/...onnection.html


 
Reply With Quote
 
 
 
 
Tony Morris
Guest
Posts: n/a
 
      05-12-2004
> How can I do this? How can I call this servlet from a java class?
>
> Any idea greatly appreciated
>
> Thanks and sorry for bad english
>
> Bye
>
> Marco



Have a look at java.net.URL.

--
Tony Morris
(BInfTech, Cert 3 I.T., SCJP[1.4], SCJD)
Software Engineer
IBM Australia - Tivoli Security Software
(2003 VTR1000F)



 
Reply With Quote
 
Chris Smith
Guest
Posts: n/a
 
      05-13-2004
Marco wrote:
> How can I do this? How can I call this servlet from a java class?
>


Most likely, one of your other responses will be helpful. If not,
please describe what you mean by "call". The phrase "call a servlet" is
not a well-defined or commonly used phrase, so everyone is guessing at
what you mean by it. You could be more specific about what you'd like
to happen, and possibly get better answers.

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
servlet help - redirecting from within a framed servlet ppcguy Java 1 08-08-2005 03:03 PM
javax.servlet.ServletException: Wrapper cannot find servlet class HARI OM Java 0 05-04-2005 10:37 PM
Offending class: javax/servlet/Servlet.class chamikara Java 1 06-19-2004 05:42 AM
Servlet question(Tomcat, web.xml, servlet-class, servlet-name) circuit_breaker Java 2 04-04-2004 03:26 AM
Tomcat: POST from one servlet or internal class to another servlet Sean Clarke Java 1 01-07-2004 02:22 PM



Advertisments