Solved

using println in a Servlet to output HTML page with button that links to another HTML page

Posted on 2004-10-05
10
429 Views
Last Modified: 2013-11-24
Could somebody provide me with a quick and dirty line of code that will output
a HTML button that when clicked allows redirects the user to another page on the website.

I can use println to make webpages, but the quoting required for the HTML is problematic for me inside println(" ") statements
0
Comment
Question by:benk-master-flash
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 12227528
System.out.println("<input type=button name=buttob value='Click Me'> onClick=show()");
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 12227553
is that what u r expecting??
0
 

Author Comment

by:benk-master-flash
ID: 12227585
OK - it makes the button i want it to link to http://localhost/core/index.jsp
can you make it do that
the onClick=show() syntax??? what is that?
0
 
LVL 12

Expert Comment

by:Giant2
ID: 12227637
System.out.println("<INPUT type=\"button\" name=\"TheButtonName\" value=\"Click Here\" onclick=\"doSomething()\">
and soSomething is a script to do someting you want when the button is clicked.

Hope this help you.
Bye, Giant.
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 12227660
System.out.println("<Script>");
System.out.println("function show(){");
System.out.println("window.location.href='http://localhost/core/index.jsp'");
System.out.println("}");
System.out.println("</Script>");

System.out.println("<input type=button name=buttob value='Click Me'> onClick=show()");
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 12

Expert Comment

by:Giant2
ID: 12227670
<SCRIPT language="JavaScript">
doSomething(){
window.open("http://localhost/core/index.jsp");
}
</SCRIPT>
0
 
LVL 14

Accepted Solution

by:
sudhakar_koundinya earned 125 total points
ID: 12227717
package org.prithvi.test;

public class Test {
  public Test() {
  }

  public static void main(String s[]) {
    System.out.println("<Script>");
    System.out.println("function show(){");
    System.out.println("window.location.href='http://localhost/core/index.jsp';");
    System.out.println("}");
    System.out.println("</Script>");

    System.out.println(
        "<input type=button name=buttob value='Click Me' onClick='show()'>");

  }
}
0
 

Author Comment

by:benk-master-flash
ID: 12228896
Thank you for your commnets both solutions work.  I have also found the below snippet works well for servlets.
<Script> tag what language is this JavaScript or vbScript
what is a good source of reference on this topic?

String orderformURL =
              response.encodeURL("../OrderForm.jsp");
        out.println
           ("<form action=\"" + orderformURL + "\">\n" +
              "<big><center>\n" +
              "<input type=\"SUBMIT\"\n" +
              "      value=\"Return to Order Form\">\n" +
              "</center></big></form>");

0
 
LVL 12

Expert Comment

by:Giant2
ID: 12234719
>both solutions work

A split could be better.
Thanks.
And sorry for not help you.
Bye, Giant.
0
 
LVL 20

Expert Comment

by:Venabili
ID: 12256509
benk-master-flash,

If two solutions are good for you, you can split the points. Do you want me to reopen it to do this?

Venabili
Java Page Editor
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now