wood burning stoves
The moose likes HTML, CSS and JavaScript and the fly likes Javascript new window is not opening from a jsp page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Javascript new window is not opening from a jsp page" Watch "Javascript new window is not opening from a jsp page" New topic

Javascript new window is not opening from a jsp page

Abhra Kar
Ranch Hand

Joined: May 22, 2008
Posts: 150

Hi I have an application “myproj5”.I am giving the entire structure of it so it will be properly understandable ,then I will say what is my requirement .

In myproj5 dir I have a redirect.jsp which contains -----

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<% response.sendRedirect("welcome.htm"); %>

In WEB-INF , web.xml contains—

<servlet-class> org.springframework.web.servlet.DispatcherServlet </servlet-class>

dispatcher-servlet.xml contains –

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

<bean id="user" class="model.User" />
<bean id="userValidator" class="validator.UserValidator" />
<bean id="viewResolver"
class=" org.springframework.web.servlet.view.InternalResourceViewResolver" >
<property name="prefix">
<property name="suffix">
<bean name="/welcome.htm" class="control.GetValueController" >
<property name="formView" value="index" />
<property name="validator"> <ref bean="userValidator"/></property>

GetValueController calss contains-----

package control;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.SimpleFormController;
import org.springframework.validation.BindException;
import model.*;
public class GetValueController extends SimpleFormController{
public GetValueController(){
protected ModelAndView onSubmit(HttpServletRequest request,
HttpServletResponse response, Object command, BindException errors)
throws Exception {
User user = (User)command;
return new ModelAndView("result","abc",user);

In WEB-INF/jsp index.jsp contains -------

<%@ taglib prefix="form" uri="/WEB-INF/spring-form.tld" %>
<link rel="stylesheet" type="text/css" href="All.css" />
<div class="third">
<form:form method="POST" commandName="user" name="createSubscriberForm">
<h3> First Name</h3>
<form:errors path="firstName" />
<form:input path="firstName" />
<h3>Last Name </h3>
<form:errors path="lastName" />
<form:input path="lastName" />
<input type="submit" value="+" onclick="javascript:requestOpenCredentialForm();"/>

In WEB-INF/jsp result.jsp contains -------

<%@ page isELIgnored="false" %>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Welcome Page</title>
<%= ((model.User)request.getAttribute("abc")).getFirstName() %>
<%= ((model.User)request.getAttribute("abc")).getLastName() %>
First Name: ${abc.firstName}
Last Name: ${abc.lastName}

So here I put some value in “index.jsp” and get those value in “result.jsp” using spring web mvc.
Now the requirement is when I will click the submit button in “index.jsp” a new window will open ,that new window will call a jsp in which some input field will be present , which I will fill up. But the class “User”(whose user id is “user”) should be populated by the value put in index.jsp.

** After putting some value in index.jsp , the application flow will not move to “result.jsp”, it will open a new window.
How I will do it ?

I tried to do onething that, I put this code in index.jsp

<input type="submit" value="+" onclick="javascript:requestOpenCredentialForm();"/>
And put this line into <head> </head>---
<script type="text/javascript" src="xxx.js"></script>

And in xxx.js contains -----

function requestOpenCredentialForm() {
document.createSubscriberForm.action = "welcome.htm?commandName=user&action=popup&page=abcd";

page=abcd(abcd is a .jsp file )
But it didn’t help me,javascript page is not opening
Please suggest what changes I will have to do .
Thanks in advance
I agree. Here's the link: http://aspose.com/file-tools
subject: Javascript new window is not opening from a jsp page
It's not a secret anymore!