• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Editing struts.xml during runtime

 
Deepti Nelavelli
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • 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?
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • 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
  • 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: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • 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
  • 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: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • 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
  • 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: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • 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.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Struts 2 action classes are most certainly not servlets, nor particularly similar.
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic