aspose file tools*
The moose likes Servlets and the fly likes Data from servlet in html Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Data from servlet in html" Watch "Data from servlet in html" New topic
Author

Data from servlet in html

Shashank Agarwal
Ranch Hand

Joined: May 20, 2004
Posts: 105
Can we make a html page get data from a servlet.

I mean, if there is a html page, its suppose to be static, but if it is supposed to show data from a servlet, can it? I want it this way instead of using jsp because this html page runs on another server which does not have jsp support.

Thanks in advance.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61426
    
  67

No.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Shashank Agarwal
Ranch Hand

Joined: May 20, 2004
Posts: 105
Why cant we do that. Just like a html file gets image from other servers cant it get text. And if the text on the other server is changed the text displayed on this html file also changes?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61426
    
  67

There is no HTML mechanism to do it. Sorry.

The closest thing is a server-side include (which is not HTML standard) but that will not let you include from another server.

Bottom line is: if you want dynamic behavior, you need a server capable of it.
Shashank Agarwal
Ranch Hand

Joined: May 20, 2004
Posts: 105
Which is the most universally accepted server script. I dont think JSP is supported by all servers, i had to search a lot to find a good one for my site. Asp i suppose is useful only with windows. What about perl and php? can they be run on any server?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61426
    
  67

Depends on the server you are running. Apache can run perl CGI scripts with the proper configuration, and php with the appropriate add-on module.
Vanessa Danin
Ranch Hand

Joined: Oct 04, 2004
Posts: 34
I am not exactly clear on what you are trying to do Shashank, so please excuse me if I am misunderstanding. However, you don't need a JSP to get data from a servlet. Why can't you invoke the servlet by using a form action, link, button or even applet which invokes the servlet? The servlet could then generate an updated HTML page using HttpServletResponse.

Since JSPs make ideal front-ends to a servlet though, what is preventing you from downloading and installing the opensource Tomcat Servlet Container which supports both servlets and JSPs? (www.jakarta.apache.org/tomcat/index.html).
Shashank Agarwal
Ranch Hand

Joined: May 20, 2004
Posts: 105
Thanks for your replies.

Actually i was trying to build a service which can be used by other webmasters. They shall put a few files (html, asp, jsp or any other) which shall have dynamic data. Since the data has to come from my servers database (which has got jsp running capablity) and displayed on their server (this servers capablities are not known) i wanted to know the best possible script available which could be run by almost all the servers. Now i think i'll give an option to the webmasters to choose between cgi and php. Please give me your opinions about this.
Vanessa Danin
Ranch Hand

Joined: Oct 04, 2004
Posts: 34
I am not familiar with server-side languages other than Java but based on a number of articles I've read, PHP and (Perl) CGI scripts remain exceptionally popular and can run on most servers. Some ISPs however may choose to provide support for ASP and exclude support for Perl and PHP as competing languages. My personal opinion is that amongst ISPs, JSPs receive less support than ASPs, whereas in the corporate environment I think JSPs are more widely used. Below is the URL (cannot include link as HTML is not enabled for this post) of an article titled "Which Server-side language is Right for You?" which may be of some value even though its focus is more on the development rather than the support perspective:
www.sitepoint.com/article/server-side-language-right

Last thought - perhaps you could consider exposing a servlet as a web service to your Java and non-Java clients.
Shashank Agarwal
Ranch Hand

Joined: May 20, 2004
Posts: 105
Thanks Vanessa,

the article was really helpful. I'm gonna make my team members read and reach a conclusion. Yes, JSP seems to be the most versatile of all and personally i preffer it over other scripts (as though i'm an expert to comment on it ) however, it has not acheived the popularity it is suppose to deserve. Well, exposing servlets to the webmaster community is a good idea but depends if they take up or not.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Data from servlet in html