This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of Darcy DeClute's Scrum Master Certification Guide: The Definitive Resource for Passing the CSM and PSM Exams and have Darcy DeClute on-line!
See this thread for details.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

Needed a logic?

 
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my JSP page am having two links called "LINK1" and "LINK2".

On click of LINK1 am displaying one DIV1 tag, where as on click of second link am disabling first DIV1 and activating second DIV2. This one am able to achieve by using javascript.


But the problem is on click of second link am calling a javascript where am enabling the DIV2 and also am submitting the page where am interacting with DB and the values should be displayed back to my JSP with enabling the DIV2.

How can I achieve this?
 
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From Javascript you can submit the form (not sure this is what you looking for) using,

And if you need to enable DIV2 do it in the "onload" of the form by calling a JS function.
 
Kartik Tal
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Vijitha,
This is not am asking for, am asking like when am submiting the page am doing some logic where the result of that logic
am transferring to same JSP.
At that time i need DIV2 to be displayed with the results.
 
Vijitha Kumara
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can set the data as attribute of one of the scopes (request,session etc..) as appropriate and also a flag (which you can use to decide whether to dispaly data or not).
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
May be you will have to include some server side code in this. First time when you load the page neither of your divs are visible. Some flag can be set which is initially false for both the divs. Once you open DIV2 and submit the page pass one request attribute after hitting the DB which jsp can read and display the div.
May be something like:

<div style="display: <%=request.getAttribute('someFlag') %>" >....</div>

I am not sure of the syntax though but something like this might work.
 
Ranch Hand
Posts: 91
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Or you can use AJAX to send data to the server and interact with db and on return back display the same in the div2 without page refresh..
 
Kartik Tal
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Muthukrishnan ,
Thanks for the suggestion, I have already opted for this. But am having a small problem with Ajax like


In my application we are keeping Headers info also in REQUEST, so while fetching back the results am getting my results+Header info, so is there any chance to divide them.
 
Muthukrishnan Manoharan
Ranch Hand
Posts: 91
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why dont you make an XML or JSON object of the response, so that you can make a clear distinction between the header information and your actual response information
 
Sheriff
Posts: 67735
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please take the time to choose the correct forum for your posts. This forum is for questions on JSP. For more information, please read this.

This post has been moved to a more appropriate forum.
 
Bear Bibeault
Sheriff
Posts: 67735
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please be sure to take the time to compose descriptive subjects for your posts; read this for more information.

A title such as "Needed a logic?" is not helpful. What would happen if all posts had such a title?

Please go back and change your post to add a more meaningful subject by clicking the button on your post.
 
Bear Bibeault
Sheriff
Posts: 67735
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Kartik Talasu wrote: [/code]In my application we are keeping Headers info also in REQUEST, so while fetching back the results am getting my results+Header info, so is there any chance to divide them.


Why? This seems like a rather odd thing to do.
 
Ranch Hand
Posts: 806
MySQL Database Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi kartik, don't go with innerHTML. Why because it works only with IE. When using chrome or firefox or any other browser it wont work.
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

anusha chaitanya wrote:Hi kartik, don't go with innerHTML. Why because it works only with IE. When using chrome or firefox or any other browser it wont work.



Not quite.

Check W3C DOM Compatibility

innerHTML works on most browsers and it is faster in most cases. IE and Konqueror have issues with tables.

There are debates about whether to use it or not, but not because it is only IE compatible. That was true in 1996, but things have moved on a bit.
 
chaitanya karthikk
Ranch Hand
Posts: 806
MySQL Database Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Peter Jennings, I'm sorry, I checked it, it is working in chrome also, I read in a forum that it wont work, but I have tried it, it's working fine on chrome also. Thanks for correcting me.
 
And will you succeed? Yes you will indeed! (98 and 3/4 % guaranteed) - Seuss. tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic