Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6575793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:25:52+00:00 2026-05-25T15:25:52+00:00

I need to open a new window from a jsp file. In a JSP

  • 0

I need to open a new window from a jsp file. In a JSP file, I take in an input from the user and then send it as an argument to a java method which returns me back the url as a string. I then need to open this in a new window. How do I do that? Below is the jsp file(send_product.jsp) for your reference.

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page import="products.*" %>
<!DOCTYPE html>
<%
    productManager pm= new productManagerImpl();
    String myUrl= null;


    if (request.getParameter("product_id") != null) {

        // get the paramter
        String product_id = request.getParameter("product_id");

        try {

            //myUrl has the url. Have to open this in a new window
            myUrl = pm.getUrl(product_id);

        } catch (Exception ex) {
            ex.printStackTrace();
        }

    }

%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Insert</title>
    </head>
    <body bgcolor="wheat">
        <h4 align="right">Send Product</h4>
        <hr color="red"/>
        <br/><br/>
        <a href="index.jsp">Index</a>
        <form action="send_product.jsp" method="post">   
            <% if (myUrl  != null && !myUrl.equals("")) {%>
            <%= myUrl%>
            <p>&nbsp;</p>

            <%
                }
            %>

            <table width="75%" align="center" >
                <tr>
                    <td>
                        Please enter the information below and click "<b>Submit</b>"
                    </td>
                </tr>
                <tr>
                    <td>
                        <fieldset title="info">
                            <table border="0" cellspacing="3" cellpadding="0" align="center">
                                <tr>
                                    <td align="right">
                                        * Product ID:
                                    </td>
                                    <td align="left">
                                        <input type="text" size="20" maxlength="70" name="product_id">
                                    </td>
                                </tr>

                            </table>
                            <hr />

                            <div align="center">
                                <input type="submit" name="saveInfo" value="Submit">
                            </div>
                        </fieldset>
                    </td>
                </tr>
            </table>
        </form>
    </body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T15:25:53+00:00Added an answer on May 25, 2026 at 3:25 pm

    You need to let your JSP print the following line of JavaScript whenever the URL has been received:

    <script>window.open('<%= myUrl%>', 'YOUR_WINDOW_NAME');</script>
    

    This way JS will open a new window/tab.


    Unrelated to the concrete question, putting Java code inside JSP like that is a poor practice. Be warned!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to open a new window from code-behind on post-back if a specific
I need PHP to open up a new window with a text from a
I need to open a new browser window from another browser window and access
All I need to open a new IE Window from within Flex code on
I used JavaScript to open a new window(child) when user clicks on button from
From Parent window I need to open a file and fill up different tables
I need to open window pop-up from Silverlight Out-of-Browser application. I've added parameter <param
I have a need to open a new window as well as redirect current
I can open a new window using window.open() in ExternalInterface.call() but then I want
I need to open a link from within jQuery but i need to avoid

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.