• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Editing struts.xml during runtime

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Consider a page consisting of a list of course names. Each of those are links which when clicked upon should open up a new jsp displaying information about the course. This of course is after retrieving details from an oracle table. How is the struts.xml to be modified during runtime?
 
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Deepti Nelavelli wrote:How is the struts.xml to be modified during runtime?


You can't edit struts.xml file during application is running, you need a context reload if you did so.

Deepti Nelavelli wrote:
Consider a page consisting of a list of course names. Each of those are links which when clicked upon should open up a new
jsp displaying information about the course. This of course is after retrieving details from an oracle table.


So you're loading menu links from database, which is generally not seen as a good practice. Why don't you hardcode links into HTML/JSP pages?
 
Deepti Nelavelli
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for that. This is a courseware development website where people create their courses, upload content and then download it for use later, very similar to sites like moodle.com. I need to display information in this manner for a moderator to approve courses that are being created. These courses and their associated information is not known while coding and is dynamic. Is there an elegant way to provide this kind of a functionality?
 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
K, Lets thought about creating a separate links (action mapping in struts.xml) for each course you add, If there are 10 users who adds 10 courses each, then its hard to maintain your struts.xml, So this solution is not at all feasible, recommended and not used, never.

Usually this things are done by using course Id and names which are passed (as a URL parameters) as per the course selected by user.

Here is How:
1. User adds course -> Course saves into db with auto generated Id/code (PK) (Database)
e.g COURSE_TABLE

2. Admin retrieves courses which are not approved yet -> So it gets listed as (JSP page)
Approve Courses:
1. My Course

3. When admin clicks for approval, on above link, the "ApproveCourses' action gets called and you can do whatever you wants with course whose id is "1".

HTH

 
Deepti Nelavelli
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That seems to be a better way to do it. I'am new to struts 2 however.How is the course_id passed as a parameter to the URL? How do you construct a query to shoot to the database from the URL parameter course_id?
 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Deepti Nelavelli wrote:I'am new to struts 2 however.


Me too

Deepti Nelavelli wrote:
How is the course_id passed as a parameter to the URL?


I had shown in the Link,
see "1. My Course" in previous reply.

Deepti Nelavelli wrote:
How do you construct a query to shoot to the database from the URL parameter course_id?


You looks like new to web application development, Still We can use JDBC in action class
 
Deepti Nelavelli
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could you please send me links of where i can find examples of passing parameters to the url in a java class? I know it is possible in a jsp. Is using servlets in struts 2 for this purpose good?
 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Deepti Nelavelli wrote:Could you please send me links of where i can find examples of passing parameters to the url in a java class?


http://www.exampledepot.com/egs/javax.servlet/GetReqParam.html?l=rel OR Google Servlets get URL parameters

Deepti Nelavelli wrote:
Is using servlets in struts 2 for this purpose good?


Struts action classes are noting but servlets.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Struts 2 action classes are most certainly not servlets, nor particularly similar.
 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David Newton wrote:Struts 2 action classes are most certainly not servlets, nor particularly similar.


Hmm interesting, I ask my doubts regrading this in a new thread
 
You don't like waffles? Well, do you like this tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic