[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: simple question on jsp



Wasn't my problem, but thanks for the reply. If you could send it to the
list next time, it helps more people. I like your solution, but I think
it is more complicated than what he needed. I am also not familiar with
the .cfm extension. Gives something new to learn today :-)
Ed.

Scott Wilkinson wrote:
> 
> Edward,
> 
> Below is a way to solve your problem using JavaScript.  Of course add your
> own action page, take out the alert and uncomment the submit.
> 
> Hope this helps!
> 
> Scott
> 
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> 
> <html>
> <head>
>  <title>Form</title>
> <script language="JavaScript">
> function changeSubmit(x)
> {
>  if(x == 1)
> 
>   document.theForm.action="action1.cfm"
>   alert(document.theForm.action)
>   //document.theForm.submit()
>  }else
>  {
>   document.theForm.action="action2.cfm"
>   alert(document.theForm.action)
>   //document.theForm.submit()
>  }
> }
> </script>
> </head>
> 
> <body>
> <form name="theForm" action=""  method="post">
>  <input type="Text" value="">
>  <input type="Button" onclick="changeSubmit(1)" value="Submit 1">
>  <input type="Button" onclick="changeSubmit(2)" value="Submit 2">
> </form>
> 
> </body>
> </html>
> ----- Original Message -----
> From: Edward Rouse <erouse@vei.net>
> To: Venky Gangu <v_gangu@enplasusa.com>
> Cc: <ajug-members@www.ajug.org>
> Sent: Wednesday, July 11, 2001 4:33 PM
> Subject: Re: simple question on jsp
> 
> > Venky Gangu wrote:
> > >
> > > Hey guys,
> > > Have a simple question (your guess is right, I am in the learning
> process).
> > >
> > > Following is a simple jsp where I have a 'text box', and 'two submit
> > > buttons'. I would like one button to process one jsp (student3a.jsp) and
> > > other to process other jsp (student3badd.jsp). Both these JSP's take the
> > > input from the text box and match the value in the text box for the
> query
> > > string and return some values from the database. For better
> understanding I
> > > have enclosed all the three jsp files ( I also have a bean which
> > > communicates with the db, but have not included here, as it is a
> > > straightforward code). Can someone, please let me know what the error
> is.
> > > Thanks for your help.
> > >
> > > If I use a html form with Action="jsp name" it is working fine, but then
> I
> > > had to use two text boxes for two buttons, and I don't want to do it
> that
> > > way (unless there is a different way in html). My goal is to have my
> first
> > > page to display a text box and two buttons, one button give me student's
> gpa
> > > and other student's course list using the concepts of jsp, javabean and
> jdbc
> > > (yes, your guess is right, this is a school assignment).
> >
> > Ok. To start, I don't like boxes, buttons, etc... that are supposed to
> > work together not being enclosed in <form> tags, but that should not be
> > a problem.
> >
> > <%
> >  if (request.getParameter("clist")=="Course List") {
> > %>
> > <jsp:forward
> > page="http://localhost:8080/examples/jsp/Venky/student3a.jsp"/>
> > <%
> >   }
> >  else {
> >  <jsp:forward
> > page="http://localhost:8080/examples/jsp/Venky/student3badd.jsp"/>
> >  }
> > %>
> >
> >
> > 1. "Course List".equals(request.getParameter("clist")) -- I know it
> > looks funny this way, but you don't need to wrry about a
> > NullPointerException if the getParameter returns a null.
> >
> > 2. else {
> > <%
> >    <jsp ----
> >  %>
> > }    ------don't forget the <jsp: tag nedds to be part of the html, not
> > the java code.
> >
> > There may be other probs as well, but those 2 stood out.
> > Ed.
> >