Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

calling servlet before jsp from jsp  RSS feed

 
chain singh
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,

please confirm me this is happen or not

i am calling a jsp page from a jsp page using javascript function window.open('hello.jsp','','').

but i want to execute a servlet file before hello.jsp file which gives date to hello.jsp file.

please also give me detail how it will call.


thanks in advance
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Give the URL to the servlet, not the JSP, to the window.open() function.

And by the way, that's not "calling a JSP".
 
chain singh
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you sir for your reply.

is this happen if i give url to jsp , not servlet , to window.open().

and related servlet called first.

thank you
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The proper approach is to use the URL of the servlet, which will be invoked and which can then forward to the JSP.
 
chain singh
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you sir for reply,

i know the proper approach sir,

all i want to know that this can be happened or not, if yes, than how?

thank you sir
 
Vijay kumarIdbi
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
put the name of servlet in wondow.open function which is registered in your web.xml then use your servlet like this

String date=code for date;
request.setAttribute("date",date);
RequestDispatcher rd = request.getRequestDispatcher("./JspPageName");//your jsp page name as registered in your web.xml file
rd.forward(request, response);


then use this date varibale in jsp for retriving date value.


Please friends if you find anything wrong in this please let me know...Thanks a lot.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stop wasting time with "can I do something weird" scenarios. If you know how to do it properly, just do it. Of course if you address the JSP, it will go to the JSP.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!