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—
<web-app>
…………………………………………..
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class> org.springframework.web.servlet.DispatcherServlet </servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>redirect.jsp</welcome-file>
</welcome-file-list>
</web-app>
dispatcher-servlet.xml contains –
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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">
<value>/WEB-INF/jsp/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
<bean name="/welcome.htm" class="control.GetValueController" >
<property name="formView" value="index" />
<property name="validator"> <ref bean="userValidator"/></property>
</bean>
</beans>
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.*;
@SuppressWarnings("deprecation")
public class GetValueController extends SimpleFormController{
public GetValueController(){
setCommandClass(User.class);
setCommandName("user");
}
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" %>
<head>
<link rel="stylesheet" type="text/css" href="All.css" />
</head>
<body>
<div class="third">
<h3>SUBSCRIBER INFORMATION </h3>
<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();"/>
</form:form>
</div>
</body>
</html>
In WEB-INF/jsp result.jsp contains -------
<%@ page isELIgnored="false" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Welcome Page</title>
</head>
<body>
<%= ((model.User)request.getAttribute("abc")).getFirstName() %>
<%= ((model.User)request.getAttribute("abc")).getLastName() %>
First Name: ${abc.firstName}
Last Name: ${abc.lastName}
</body>
</html>
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";
document.createSubscriberForm.submit();
}
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