|
|
Run a Servlet Without a Submit Button
I am new to Java and am trying to figure out how to run a servlet
without the need for a user to click a submit button. I have a web
service that converts a file to PDF and then a servlet that displays
the PDF file in the browser. Here is the code I have in the JSP:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<META http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<META name="GENERATOR" content="IBM Software Development Platform">
<META http-equiv="Content-Style-Type" content="text/css">
<LINK href="theme/Master.css" rel="stylesheet"
type="text/css">
<TITLE>IgRetConvTest.jsp</TITLE>
</HEAD>
<BODY>
<H1>Retrieve and Convert</H1>
<jsp:useBean id="proxy"
class="getconvert.IgRetConvProxy"></jsp:useBean>
<%
session.setAttribute("filename",
String.valueOf(proxy.retrieveConvert("<?xml version='1.0'
encoding='UTF-8'
?><IMG-PATH>C:\\\\TEST\\</IMG-PATH><IMG-NAM>TEST.IMG</IMG-NAM>")));
%>
<FORM action="/IgRetConvClient/PDFDisplay" method="post">
<INPUT type="submit" name="Submit" value="Display Image">
</FORM>
</BODY>
</HTML>
How can I run "/IgRetConvClient/PDFDisplay" without using "submit"?
|
|
0
|
|
|
|
Reply
|
dmckeon (34)
|
6/14/2006 2:18:42 PM |
|
<dmckeon@ameritas.com> wrote in message
news:1150294722.618566.235780@h76g2000cwa.googlegroups.com...
>I am new to Java and am trying to figure out how to run a servlet
> without the need for a user to click a submit button. I have a web
> service that converts a file to PDF and then a servlet that displays
> the PDF file in the browser. Here is the code I have in the JSP:
[most of the code snipped]
> <FORM action="/IgRetConvClient/PDFDisplay" method="post">
> <INPUT type="submit" name="Submit" value="Display Image">
> </FORM>
[...]
>
>
> How can I run "/IgRetConvClient/PDFDisplay" without using "submit"?
The user has to somehow navigate to that URL. There are many ways to
this that don't involve clicking on a button labelled "Submit". One of them
is to type in the URL directly into the browser's address bar, for example.
- Oliver
|
|
0
|
|
|
|
Reply
|
owong (5281)
|
6/14/2006 2:25:58 PM
|
|
Oliver Wong wrote:
> <dmckeon@ameritas.com> wrote in message
> news:1150294722.618566.235780@h76g2000cwa.googlegroups.com...
> >I am new to Java and am trying to figure out how to run a servlet
> > without the need for a user to click a submit button. I have a web
> > service that converts a file to PDF and then a servlet that displays
> > the PDF file in the browser. Here is the code I have in the JSP:
>
> [most of the code snipped]
> > <FORM action="/IgRetConvClient/PDFDisplay" method="post">
> > <INPUT type="submit" name="Submit" value="Display Image">
> > </FORM>
> [...]
> >
> >
> > How can I run "/IgRetConvClient/PDFDisplay" without using "submit"?
>
> The user has to somehow navigate to that URL. There are many ways to
> this that don't involve clicking on a button labelled "Submit". One of them
> is to type in the URL directly into the browser's address bar, for example.
>
> - Oliver
All of the code I supplied is in a JSP. If the user navigates to the
JSP I need a way to run the servlet without them clicking "submit".
Can you give me some specific examples of how to do that?
|
|
0
|
|
|
|
Reply
|
dmckeon (34)
|
6/14/2006 2:34:17 PM
|
|
<dmckeon@ameritas.com> wrote in message
news:1150295656.962168.6640@i40g2000cwc.googlegroups.com...
>
> Oliver Wong wrote:
>> <dmckeon@ameritas.com> wrote in message
>> news:1150294722.618566.235780@h76g2000cwa.googlegroups.com...
>> >I am new to Java and am trying to figure out how to run a servlet
>> > without the need for a user to click a submit button. I have a web
>> > service that converts a file to PDF and then a servlet that displays
>> > the PDF file in the browser. Here is the code I have in the JSP:
>>
>> [most of the code snipped]
>> > <FORM action="/IgRetConvClient/PDFDisplay" method="post">
>> > <INPUT type="submit" name="Submit" value="Display Image">
>> > </FORM>
>> [...]
>> >
>> >
>> > How can I run "/IgRetConvClient/PDFDisplay" without using "submit"?
>>
>> The user has to somehow navigate to that URL. There are many ways to
>> this that don't involve clicking on a button labelled "Submit". One of
>> them
>> is to type in the URL directly into the browser's address bar, for
>> example.
>>
>
> All of the code I supplied is in a JSP. If the user navigates to the
> JSP I need a way to run the servlet without them clicking "submit".
> Can you give me some specific examples of how to do that?
Doesn't the user navigating directly to
http://[yourserver]/IgRetConvClient/PDFDisplay cause the servlet to run?
- Oliver
|
|
0
|
|
|
|
Reply
|
owong (5281)
|
6/14/2006 2:58:04 PM
|
|
Oliver Wong wrote:
> <dmckeon@ameritas.com> wrote in message
> news:1150295656.962168.6640@i40g2000cwc.googlegroups.com...
> >
> > Oliver Wong wrote:
> >> <dmckeon@ameritas.com> wrote in message
> >> news:1150294722.618566.235780@h76g2000cwa.googlegroups.com...
> >> >I am new to Java and am trying to figure out how to run a servlet
> >> > without the need for a user to click a submit button. I have a web
> >> > service that converts a file to PDF and then a servlet that displays
> >> > the PDF file in the browser. Here is the code I have in the JSP:
> >>
> >> [most of the code snipped]
> >> > <FORM action="/IgRetConvClient/PDFDisplay" method="post">
> >> > <INPUT type="submit" name="Submit" value="Display Image">
> >> > </FORM>
> >> [...]
> >> >
> >> >
> >> > How can I run "/IgRetConvClient/PDFDisplay" without using "submit"?
> >>
> >> The user has to somehow navigate to that URL. There are many ways to
> >> this that don't involve clicking on a button labelled "Submit". One of
> >> them
> >> is to type in the URL directly into the browser's address bar, for
> >> example.
> >>
> >
> > All of the code I supplied is in a JSP. If the user navigates to the
> > JSP I need a way to run the servlet without them clicking "submit".
> > Can you give me some specific examples of how to do that?
>
> Doesn't the user navigating directly to
> http://[yourserver]/IgRetConvClient/PDFDisplay cause the servlet to run?
>
> - Oliver
That's not the way it's structured or the way we need it to work.
|
|
0
|
|
|
|
Reply
|
dmckeon (34)
|
6/14/2006 3:02:41 PM
|
|
Oliver Wong wrote:
> <dmckeon@ameritas.com> wrote in message
> news:1150295656.962168.6640@i40g2000cwc.googlegroups.com...
> >
> > Oliver Wong wrote:
> >> <dmckeon@ameritas.com> wrote in message
> >> news:1150294722.618566.235780@h76g2000cwa.googlegroups.com...
> >> >I am new to Java and am trying to figure out how to run a servlet
> >> > without the need for a user to click a submit button. I have a web
> >> > service that converts a file to PDF and then a servlet that displays
> >> > the PDF file in the browser. Here is the code I have in the JSP:
> >>
> >> [most of the code snipped]
> >> > <FORM action="/IgRetConvClient/PDFDisplay" method="post">
> >> > <INPUT type="submit" name="Submit" value="Display Image">
> >> > </FORM>
> >> [...]
> >> >
> >> >
> >> > How can I run "/IgRetConvClient/PDFDisplay" without using "submit"?
> >>
> >> The user has to somehow navigate to that URL. There are many ways to
> >> this that don't involve clicking on a button labelled "Submit". One of
> >> them
> >> is to type in the URL directly into the browser's address bar, for
> >> example.
> >>
> >
> > All of the code I supplied is in a JSP. If the user navigates to the
> > JSP I need a way to run the servlet without them clicking "submit".
> > Can you give me some specific examples of how to do that?
>
> Doesn't the user navigating directly to
> http://[yourserver]/IgRetConvClient/PDFDisplay cause the servlet to run?
>
> - Oliver
I'm sorry -- I think I know what you mean. Are you suggesting I use a
redirect???
|
|
0
|
|
|
|
Reply
|
dmckeon (34)
|
6/14/2006 3:06:56 PM
|
|
<dmckeon@ameritas.com> wrote in message
news:1150297616.668735.314080@u72g2000cwu.googlegroups.com...
>
> Oliver Wong wrote:
>> <dmckeon@ameritas.com> wrote in message
>> news:1150295656.962168.6640@i40g2000cwc.googlegroups.com...
>> >
>> > Oliver Wong wrote:
>> >> <dmckeon@ameritas.com> wrote in message
>> >> news:1150294722.618566.235780@h76g2000cwa.googlegroups.com...
>> >> >I am new to Java and am trying to figure out how to run a servlet
>> >> > without the need for a user to click a submit button. I have a web
>> >> > service that converts a file to PDF and then a servlet that displays
>> >> > the PDF file in the browser. Here is the code I have in the JSP:
>> >>
>> >> [most of the code snipped]
>> >> > <FORM action="/IgRetConvClient/PDFDisplay" method="post">
>> >> > <INPUT type="submit" name="Submit" value="Display Image">
>> >> > </FORM>
>> >> [...]
>> >> >
>> >> >
>> >> > How can I run "/IgRetConvClient/PDFDisplay" without using "submit"?
>> >>
>> >> The user has to somehow navigate to that URL. There are many ways
>> >> to
>> >> this that don't involve clicking on a button labelled "Submit". One of
>> >> them
>> >> is to type in the URL directly into the browser's address bar, for
>> >> example.
>> >>
>> >
>> > All of the code I supplied is in a JSP. If the user navigates to the
>> > JSP I need a way to run the servlet without them clicking "submit".
>> > Can you give me some specific examples of how to do that?
>>
>> Doesn't the user navigating directly to
>> http://[yourserver]/IgRetConvClient/PDFDisplay cause the servlet to run?
>>
>> - Oliver
>
> I'm sorry -- I think I know what you mean. Are you suggesting I use a
> redirect???
Well, I wanted to get a yes-or-no answer to my question to check if my
assumptions were correct. Assuming they ARE correct, what I'm basically
saying is that there is virtually an infinite number of ways to get the
servelet to run, depending on what you want. All that needs to be done is to
ensure that the client eventually navigates to that link.
So you could use a form, or an <a href="/path/to/your/servlet"> link, or
a redirect, or javascript, or an applet, or a ShockWave flash animation, or
a Windows .url shortcut, etc.
- Oliver
|
|
0
|
|
|
|
Reply
|
owong (5281)
|
6/14/2006 3:54:54 PM
|
|
Google sometimes does it by having an <img> tag href to a servlet that
returns something unimportant to the browser. the <img> tag can have a
size 0 so it does not interrupt the page.
|
|
0
|
|
|
|
Reply
|
christopher3279 (52)
|
6/15/2006 12:01:06 AM
|
|
dmckeon@ameritas.com wrote:
> Oliver Wong wrote:
> > <dmckeon@ameritas.com> wrote in message
> > news:1150294722.618566.235780@h76g2000cwa.googlegroups.com...
> > >I am new to Java and am trying to figure out how to run a servlet
> > > without the need for a user to click a submit button. I have a web
> > > service that converts a file to PDF and then a servlet that displays
> > > the PDF file in the browser. Here is the code I have in the JSP:
> >
> > [most of the code snipped]
> > > <FORM action="/IgRetConvClient/PDFDisplay" method="post">
> > > <INPUT type="submit" name="Submit" value="Display Image">
> > > </FORM>
> > [...]
> > >
> > >
> > > How can I run "/IgRetConvClient/PDFDisplay" without using "submit"?
> >
> > The user has to somehow navigate to that URL. There are many ways to
> > this that don't involve clicking on a button labelled "Submit". One of them
> > is to type in the URL directly into the browser's address bar, for example.
> >
> > - Oliver
>
> All of the code I supplied is in a JSP. If the user navigates to the
> JSP I need a way to run the servlet without them clicking "submit".
> Can you give me some specific examples of how to do that?
Well if I understand you correctly, just make the following change to
your jsp :
<BODY onLoad="document.forms[0].submit();">
that will cause the form to auto-submit when your jsp is called. No
need for the user to hit a submit button.
(btw. this is more a javascript question)
/Steen
|
|
0
|
|
|
|
Reply
|
steen (31)
|
6/15/2006 9:28:17 AM
|
|
steen wrote:
> dmckeon@ameritas.com wrote:
> > Oliver Wong wrote:
> > > <dmckeon@ameritas.com> wrote in message
> > > news:1150294722.618566.235780@h76g2000cwa.googlegroups.com...
> > > >I am new to Java and am trying to figure out how to run a servlet
> > > > without the need for a user to click a submit button. I have a web
> > > > service that converts a file to PDF and then a servlet that displays
> > > > the PDF file in the browser. Here is the code I have in the JSP:
> > >
> > > [most of the code snipped]
> > > > <FORM action="/IgRetConvClient/PDFDisplay" method="post">
> > > > <INPUT type="submit" name="Submit" value="Display Image">
> > > > </FORM>
> > > [...]
> > > >
> > > >
> > > > How can I run "/IgRetConvClient/PDFDisplay" without using "submit"?
> > >
> > > The user has to somehow navigate to that URL. There are many ways to
> > > this that don't involve clicking on a button labelled "Submit". One of them
> > > is to type in the URL directly into the browser's address bar, for example.
> > >
> > > - Oliver
> >
> > All of the code I supplied is in a JSP. If the user navigates to the
> > JSP I need a way to run the servlet without them clicking "submit".
> > Can you give me some specific examples of how to do that?
>
> Well if I understand you correctly, just make the following change to
> your jsp :
> <BODY onLoad="document.forms[0].submit();">
>
> that will cause the form to auto-submit when your jsp is called. No
> need for the user to hit a submit button.
>
> (btw. this is more a javascript question)
>
> /Steen
<BODY onLoad="document.forms[0].submit();"> works like a charm!!!
Thanks so much (and sorry for posting in the wrong group)!
|
|
0
|
|
|
|
Reply
|
dmckeon (34)
|
6/15/2006 2:23:00 PM
|
|
|
9 Replies
15 Views
(page loaded in 0.122 seconds)
|
|
|
|
|
|
|
|
|