This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How and where to call servlets in JSP?  RSS feed

 
Al Kaiser
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • 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?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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?
 
Prakash Dwivedi
Ranch Hand
Posts: 452
  • Mark post as helpful
  • send pies
  • 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
  • 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>
(...)
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!