• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How and where to call servlets in JSP?

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have some servlets which themselves can't run. But, I can run from JSP and I'd like to know desperately how to call those servlets from JSP.

Do I include this tag in the body or before HTML tags?
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I have some servlets which themselves can't run.


I'm not sure what you mean by this.


But, I can run from JSP and I'd like to know desperately how to call those servlets from JSP.


Are you merely trying to use the JSP simply as a means to invoke the servlet? If so, I'd say back up and let's address the real problem: why you can't invoke the servlets.
[ March 02, 2004: Message edited by: Bear Bibeault ]
 
Al Kaiser
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm using IDE JDeveloper and in there you can't run a servlet standalone. You need a JSP page to call the servlets.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Kneejerk reaction: if that's the case, get yourself a real IDE. An IDE is supposed to help you get your work done, not make you set up artificial constructs to get things done.
Calmer reaction: the simplest way to invoke (a better term than "call") a servlet from a JSP is with the jsp:forward action. No HTML, no nothing. Just the forward. But to do that, you need the URL formed by the servlet mapping for the servlet which you would have set up in the web.xml file. (Though if you have that, why won't the IDE let you invoke it the same way as a JSP?)
Have you asked in the IDEs forum about using JDeveloper and servlets?
 
Ranch Hand
Posts: 452
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Al Kaiser:
I'm using IDE JDeveloper and in there you can't run a servlet standalone. You need a JSP page to call the servlets.


servlets are not standalone desktop application. To test them you need some client which is an html page. You can use jsp to generate html page, but in the end it is html only.
to call a servlet from a html page (or jsp), there are many ways. Like
<form action="/myServlet">
</form>
In web.xml map your servlet to "/myServlet" in servlet-mapping
 
Al Kaiser
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The follwoing don't work. Returns error 500:

(...)
</head>
<body>
<h2>
Hi-vol Spider is loading
<jsp:include page="/SpiderWorker" />
<form action="/Spider">
</form>
</h2>
<p>
(...)
 
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not sure whether the dynamic inclusion can work with a Servlet.
That is, I wonder whether this work:

Usually, the page should be a JSP page.
But the rest of the code seems ok.
Nick.
reply
    Bookmark Topic Watch Topic
  • New Topic